Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options
- {
- LOOKAHEAD= 1;
- MULTI = true;
- NODE_SCOPE_HOOK=true;
- }
- PARSER_BEGIN(Reader)
- public class Reader {
- Reader parser;
- public static void main(String args[]) throws ParseException {
- System.out.println("Java-- Parser");
- parser = new Reader(System.in);
- try {
- parser.Global();
- System.out.println("Java-- Finished Parsing");
- } catch (ParseException e) {
- System.out.println(e.getMessage());
- System.out.println("Java-- Error Parsing");
- }
- }
- }
- PARSER_END(Reader)
- //White Spaces
- SKIP :
- {
- " "
- | "\t"
- | "\n"
- | "\r"
- | "\f"
- }
- //Keywords
- TOKEN :
- {
- < CLASS: "class" >
- | < PUBLIC: "public" >
- | < STATIC: "static" >
- | < NEW: "new" >
- | < EXTENDS: "extends" >
- | < FALSE: "false" >
- | < TRUE: "true" >
- | < IF: "if" >
- | < ELSE: "else" >
- | < BOOLEAN: "boolean" >
- | < INT: "int" >
- | < RETURN: "return" >
- | < VOID: "void" >
- | < WHILE: "while" >
- }
- void Global() : {}
- {
- Class()
- <EOF>
- }
- void Class() : {}
- {
- ClassDeclaration()
- ";"
- }
- void ClassDeclaration() : {}
- {
- ( "public" | "static" )*
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement