|
|
@ -2,6 +2,7 @@ package chocopy.pa1;
|
|
|
|
import java_cup.runtime.*;
|
|
|
|
import java_cup.runtime.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
|
/*** Do not change the flags below unless you know what you are doing. ***/
|
|
|
|
/*** Do not change the flags below unless you know what you are doing. ***/
|
|
|
@ -81,6 +82,7 @@ import java.util.Iterator;
|
|
|
|
WhiteSpace = [ \t]
|
|
|
|
WhiteSpace = [ \t]
|
|
|
|
LineBreak = \r|\n|\r\n
|
|
|
|
LineBreak = \r|\n|\r\n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IntegerLiteral = 0|[1-9][0-9]* // Accroding to the manual, 00+ is illeagal
|
|
|
|
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])*
|
|
|
|
Identifiers = (_|[a-z]|[A-Z])(_|[a-z]|[A-Z]|[0-9])*
|
|
|
@ -188,6 +190,7 @@ if True:
|
|
|
|
/* Literals. */
|
|
|
|
/* Literals. */
|
|
|
|
{IntegerLiteral} { return symbol(ChocoPyTokens.NUMBER,
|
|
|
|
{IntegerLiteral} { return symbol(ChocoPyTokens.NUMBER,
|
|
|
|
Integer.parseInt(yytext())); }
|
|
|
|
Integer.parseInt(yytext())); }
|
|
|
|
|
|
|
|
|
|
|
|
"\"" {yybegin(STR); str_l = yyline + 1; str_c = yycolumn + 1; currString = "";} //Start taking a string when see a "
|
|
|
|
"\"" {yybegin(STR); str_l = yyline + 1; str_c = yycolumn + 1; currString = "";} //Start taking a string when see a "
|
|
|
|
"False" { return symbol(ChocoPyTokens.BOOL, false); }
|
|
|
|
"False" { return symbol(ChocoPyTokens.BOOL, false); }
|
|
|
|
"True" { return symbol(ChocoPyTokens.BOOL, true); }
|
|
|
|
"True" { return symbol(ChocoPyTokens.BOOL, true); }
|
|
|
|