Basic support for ampersand and backslash characters. At least the parser now accepts these characters and can parse a lot more typical scripts.
This commit is contained in:
@ -301,7 +301,7 @@ ASTDDLCommand DDLCommand() :
|
||||
|
||||
ASTSqlPlusCommand SqlPlusCommand() :
|
||||
{
|
||||
StringBuilder sb = new StringBuilder() ;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
}
|
||||
{
|
||||
(
|
||||
@ -337,11 +337,10 @@ ASTSqlPlusCommand SqlPlusCommand() :
|
||||
// Attach Library
|
||||
| "." <ATTACH>
|
||||
)
|
||||
{ sb.append(token.getImage()) ; sb.append(" ...") ; }
|
||||
Skip2NextTokenOccurrence(EOL) //Tracker Issue 1433480 skip until next EOL Special Token
|
||||
//[";" | "-"]
|
||||
{ sb.append(token.getImage()) ; sb.append(" ") ; sb.append(Read2NextTokenOccurrence(EOL).getImage()) ;
|
||||
}
|
||||
)
|
||||
{ jjtThis.setImage(sb.toString()) ; return jjtThis ; }
|
||||
{ jjtThis.setImage(sb.toString()) ; return jjtThis ; }
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1140,6 +1139,28 @@ ASTRead2NextOccurrence Read2NextOccurrence(String target) :
|
||||
{ jjtThis.setImage(sb.toString()) ; jjtThis.value = sb.toString(); return jjtThis ;}
|
||||
}
|
||||
|
||||
/*
|
||||
Read Tokens up to but not including the target token.
|
||||
*/
|
||||
ASTRead2NextTokenOccurrence Read2NextTokenOccurrence(int target) :
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Token nextToken = getToken(1);
|
||||
while (nextToken.kind!=target
|
||||
&& (null == nextToken.specialToken || nextToken.specialToken.kind!=target ) //In case the target is a Special Token
|
||||
&& nextToken.kind!=EOF
|
||||
)
|
||||
{
|
||||
nextToken = getNextToken();
|
||||
sb.append(nextToken.getImage());
|
||||
sb.append(' ');
|
||||
nextToken = getToken(1);
|
||||
}
|
||||
}
|
||||
{
|
||||
{ jjtThis.setImage(sb.toString()) ; jjtThis.value = sb.toString(); return jjtThis ;}
|
||||
}
|
||||
|
||||
/*
|
||||
Read Tokens up to and including the target String.
|
||||
*/
|
||||
@ -5077,13 +5098,21 @@ TOKEN :
|
||||
|
|
||||
< #_CHARACTER_WO_ASTERISK: <LETTER> | <DIGIT> | "(" | ")" | "+" | "-" | "*" | "/" | "<" | ">"
|
||||
| "=" | "!" | "~" | "^" | ";" | ":" | "." | "@" | "%" | "," | "\"" | "#"
|
||||
| "$" | "&" | "_" | "|" | "{" | "}" | "?" | "[" | "]"
|
||||
| "$" | "_" | "|" | "{" | "}" | "?" | "[" | "]"
|
||||
| " " | "\t" >
|
||||
|
|
||||
< #SPECIAL_CHARACTERS: "á" | "Ž" | "™" | "š" | "„" | "”" | "ý" | "²" | "€" | "³" | "µ">
|
||||
|
|
||||
< #DELIMITER: "+" | "%" | "'" | "\"" | "." | "/" | "(" | ")" | ":" | "," | "*" | "=" | "<" | ">" | "@" | ";" | "-">
|
||||
|
|
||||
<ESCAPED_AMPERSAND:
|
||||
"\\&"
|
||||
>
|
||||
|
|
||||
<BACKSLASH:
|
||||
"\\"
|
||||
>
|
||||
|
|
||||
< IDENTIFIER:
|
||||
( ("$" | ":" | <LETTER>) ( <LETTER> | <DIGIT> | "$" | "_" | "#" )* ) // 2006-05-17 - Matthias Hendler - Bind variablen werden nun als Identifier akzeptiert.
|
||||
//SRT Does NOT seem to like identifiers 2 or fewer characters( <LETTER> ( <LETTER> ) )
|
||||
@ -5091,6 +5120,14 @@ TOKEN :
|
||||
//( <LETTER> ( "$" ) )
|
||||
//( <LETTER> ( "_" ) )
|
||||
//( <LETTER> ( "#" ) )
|
||||
|
|
||||
(
|
||||
"&"
|
||||
(
|
||||
( <LETTER> | "_" ) ( <LETTER> | <DIGIT> | "$" | "_" | "#" )+
|
||||
(".")?
|
||||
)?
|
||||
)
|
||||
|
|
||||
( (<LETTER> | "$" ) ( <LETTER> | <DIGIT> | "$" | "_" | "#" )* )
|
||||
|
|
||||
@ -5098,6 +5135,16 @@ TOKEN :
|
||||
( "\"" <LETTER> ( <LETTER> | <DIGIT> | "$" | "_" | "#" )* "\"" )
|
||||
>
|
||||
|
|
||||
< LEXICAL_PARAMETER:
|
||||
(
|
||||
"&"
|
||||
(
|
||||
( <LETTER> | <DIGIT> | "$" | "_" | "#" )+
|
||||
(".")?
|
||||
)?
|
||||
)
|
||||
>
|
||||
|
|
||||
< UNSIGNED_NUMERIC_LITERAL: <FLOAT_LITERAL> ( ["e","E"] (["-","+"])? <FLOAT_LITERAL> )? (["f","F","d","D"])? >
|
||||
|
|
||||
< #FLOAT_LITERAL: <INTEGER_LITERAL> ( "." <INTEGER_LITERAL> )? | "." <INTEGER_LITERAL> >
|
||||
|
@ -165,6 +165,11 @@ public class PLSQLParserVisitorAdapter implements PLSQLParserVisitor {
|
||||
public Object visit(ASTRead2NextOccurrence node, Object data) {
|
||||
return visit((PLSQLNode) node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTRead2NextTokenOccurrence node, Object data) {
|
||||
return visit((PLSQLNode) node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTReadPastNextOccurrence node, Object data) {
|
||||
|
@ -161,6 +161,7 @@ import net.sourceforge.pmd.lang.plsql.ast.ASTQueryBlock;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTQueryPartitionClause;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTRaiseStatement;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTRead2NextOccurrence;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTRead2NextTokenOccurrence;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTReadPastNextOccurrence;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTReferencesClause;
|
||||
import net.sourceforge.pmd.lang.plsql.ast.ASTRegexpLikeCondition;
|
||||
@ -482,6 +483,11 @@ public abstract class AbstractPLSQLRule extends AbstractRule implements PLSQLPar
|
||||
return visit((PLSQLNode) node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTRead2NextTokenOccurrence node, Object data) {
|
||||
return visit((PLSQLNode) node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTReadPastNextOccurrence node, Object data) {
|
||||
return visit((PLSQLNode) node, data);
|
||||
|
Reference in New Issue
Block a user