diff --git a/src/main/cup/chocopy/pa1/ChocoPy.cup b/src/main/cup/chocopy/pa1/ChocoPy.cup index 20db76b..1bcb484 100644 --- a/src/main/cup/chocopy/pa1/ChocoPy.cup +++ b/src/main/cup/chocopy/pa1/ChocoPy.cup @@ -259,7 +259,7 @@ non terminal VarDef var_def; non terminal ClassDef class_def; non terminal FuncDef fun_def; non terminal Literal literal; -non terminal StringLiteral bin_op, comp_op; +non terminal StringLiteral bin_op, comp_op; non terminal TypedVar typed_var; non terminal TypeAnnotation type, ret_type; non terminal Identifier identifier; diff --git a/src/main/jflex/chocopy/pa1/ChocoPy.jflex b/src/main/jflex/chocopy/pa1/ChocoPy.jflex index de6ec6c..c297fab 100644 --- a/src/main/jflex/chocopy/pa1/ChocoPy.jflex +++ b/src/main/jflex/chocopy/pa1/ChocoPy.jflex @@ -2,6 +2,7 @@ package chocopy.pa1; import java_cup.runtime.*; import java.util.ArrayList; import java.util.Iterator; + %% /*** Do not change the flags below unless you know what you are doing. ***/ @@ -81,6 +82,7 @@ import java.util.Iterator; 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 " Identifiers = (_|[a-z]|[A-Z])(_|[a-z]|[A-Z]|[0-9])* @@ -188,6 +190,7 @@ if True: /* Literals. */ {IntegerLiteral} { return symbol(ChocoPyTokens.NUMBER, Integer.parseInt(yytext())); } + "\"" {yybegin(STR); str_l = yyline + 1; str_c = yycolumn + 1; currString = "";} //Start taking a string when see a " "False" { return symbol(ChocoPyTokens.BOOL, false); } "True" { return symbol(ChocoPyTokens.BOOL, true); }