|
|
|
@ -33,7 +33,7 @@ import java.util.ArrayList;
|
|
|
|
|
/** Producer of token-related values for the parser. */
|
|
|
|
|
final ComplexSymbolFactory symbolFactory = new ComplexSymbolFactory();
|
|
|
|
|
private int currIndent = 0; //Current Indentation Level
|
|
|
|
|
private int currString = "";
|
|
|
|
|
private String currString = "";
|
|
|
|
|
/*A stack that keeps track of the spaces in each Indentation Level*/
|
|
|
|
|
private ArrayList<Integer> stack = new ArrayList<Integer>(20);
|
|
|
|
|
/** Return a terminal symbol of syntactic category TYPE and no
|
|
|
|
@ -70,7 +70,7 @@ WhiteSpace = [ \t]
|
|
|
|
|
LineBreak = \r|\n|\r\n
|
|
|
|
|
|
|
|
|
|
IntegerLiteral = 0|[1-9][0-9]* // Accroding to the manual, 00+ is illeagal
|
|
|
|
|
StringLiteral = ([^\"\\]|(\\\")|(\\t)|(\\r)|(\\n)|(\\\\))* // \n, \r, \t, \\, \" and Anything except \ and "
|
|
|
|
|
StringLiteral = ([^\"\\]|(\\\")|(\\t)|(\\r)|(\\n)|(\\\\))+ // \n, \r, \t, \\, \" and Anything except \ and "
|
|
|
|
|
Identifiers = (_|[a-z]|[A-Z])(_|[a-z]|[A-Z][0-9])*
|
|
|
|
|
Comments = #[^\r\n]*
|
|
|
|
|
%%
|
|
|
|
@ -138,7 +138,7 @@ if True:
|
|
|
|
|
}
|
|
|
|
|
/*Otherwise, we will start dealing with the rest
|
|
|
|
|
of the line after indentation in AFTER state. */
|
|
|
|
|
yystart(AFTER);
|
|
|
|
|
yybegin(AFTER);
|
|
|
|
|
if(top()< currIndent)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
@ -160,7 +160,7 @@ if True:
|
|
|
|
|
/* Literals. */
|
|
|
|
|
{IntegerLiteral} { return symbol(ChocoPyTokens.NUMBER,
|
|
|
|
|
Integer.parseInt(yytext())); }
|
|
|
|
|
"\"" {yystart(STR); currString = "";} //Start taking a string when see a "
|
|
|
|
|
"\"" {yybegin(STR); currString = "";} //Start taking a string when see a "
|
|
|
|
|
"False" { return symbol(ChocoPyTokens.BOOL, false); }
|
|
|
|
|
"True" { return symbol(ChocoPyTokens.BOOL, true); }
|
|
|
|
|
"None" { return symbol(ChocoPyTokens.NONE); }
|
|
|
|
|