Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package atividade1;
- %%
- /* Não altere as configurações a seguir */
- %line
- %column
- %unicode
- //%debug
- %public
- %standalone
- %class Minijava
- %eofclose
- /* Insira as regras léxicas abaixo */
- endLine = \r
- | \n
- | \r\n
- whiteSpace = {endLine} | [ \t\f]
- inputCharacter = [^\r\n]
- oneLineComment = "/" {inputCharacter}* {endLine}?
- multipleLineComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
- commentText = ([^*] | \*+[^/*])*
- documentationComment = "/**" {commentText} "*"+ "/"
- comment = {multipleLineComment}
- | {oneLineComment}
- | {documentationComment}
- reserved = "boolean"
- | "class"
- | "else"
- | "extends"
- | "false"
- | "if"
- | "int"
- | "length"
- | "main"
- | "new"
- | "public"
- | "return"
- | "static"
- | "String"
- | "System.out.println"
- | "this"
- | "true"
- | "void"
- | "while"
- operators = &&
- | "=="
- | "<"
- | "!="
- | "+"
- | "-"
- | "*"
- | "!"
- delimiters = ";"
- | "."
- | ","
- | "="
- | "("
- | ")"
- | "{"
- | "}"
- | "["
- | "]"
- letter = [A-Za-z]
- digit = [0-9]
- underline = [_]
- integer = [1-9]{digit}* | 0
- expression = {underline} | {digit} | {letter}
- identifier = ({letter} | {underline})({expression})*
- %%
- {reserved} { System.out.println("token gerado foi um reservado: '" + yytext() + "' na linha: "
- + yyline + ", coluna: " + yycolumn); }
- {operators} { System.out.println("token gerado foi um operador: '" + yytext() + "' na linha: "
- + yyline + ", coluna: " + yycolumn); }
- {delimiters} { System.out.println("token gerado foi um delimitador: '" + yytext() + "' na linha: "
- + yyline + ", coluna: " + yycolumn); }
- {identifier} { System.out.println("token gerado foi um id: '" + yytext() + "' na linha: "
- + yyline + ", coluna: " + yycolumn); }
- {integer} { System.out.println("token gerado foi um integer: '" + yytext() + "' na linha: "
- + yyline + ", coluna: " + yycolumn); }
- {comment} { /* Comentários. */ }
- {whiteSpace} { /* Whitespace. */ }
- /* Insira as regras léxicas no espaço acima */
- . { throw new RuntimeException("Caractere ilegal! '" + yytext() + "' na linha: " + yyline + ", coluna: " + yycolumn); }
Add Comment
Please, Sign In to add comment