[hw2]YuhianLexer
specification:
identify : 由letter digit '_'(underscore)組成
key word :
"globle" , "variables" , "prototypes" , "classes" , "classdef" , "class" ,"int" , "boolean",
"string" , "true" , "false" , "unless" , "else" , "else" , "do" , "while", "print" , "return",
"readInt" , "readString".
Keywords and identifiers must be separated by white space or a token that is neither a keyword or an identifier.
skip:
" "(white space) ,"\t"(tab),"\n"(newline)
operator:
Binary : && , || , == , < , > , + , - , * , / , % .
Unary operator : !
Other special characters: “{“, “}”, “(“, “)”, “[“, “]”, “;”, “,”, “.”, “=“
command:
line comment //
comment /**/ Unclosed comments are lexical errors
String :
"string"=>sequece of characters enclose in double quotes
\" => "
\\=> \
\t => tab
\n => newline
no negative integer literals
Non-Zero number should not have leading zeros
數字最大到2^31-1
Boolean => true or false
identify : 由letter digit '_'(underscore)組成
key word :
"globle" , "variables" , "prototypes" , "classes" , "classdef" , "class" ,"int" , "boolean",
"string" , "true" , "false" , "unless" , "else" , "else" , "do" , "while", "print" , "return",
"readInt" , "readString".
Keywords and identifiers must be separated by white space or a token that is neither a keyword or an identifier.
skip:
" "(white space) ,"\t"(tab),"\n"(newline)
operator:
Binary : && , || , == , < , > , + , - , * , / , % .
Unary operator : !
Other special characters: “{“, “}”, “(“, “)”, “[“, “]”, “;”, “,”, “.”, “=“
command:
line comment //
comment /**/ Unclosed comments are lexical errors
String :
"string"=>sequece of characters enclose in double quotes
\" => "
\\=> \
\t => tab
\n => newline
Unclosed strings are lexical errors.
no negative integer literals
Non-Zero number should not have leading zeros
數字最大到2^31-1
Boolean => true or false
留言
張貼留言