/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. FramclipseNonScriptParser.jj */ /*@egen*/options { JDK_VERSION = "1.5"; USER_CHAR_STREAM = true; STATIC = false; } PARSER_BEGIN(FramclipseNonScriptParser) package com.framsticks.framclipse.internal.parser; import java.io.StringReader; public class FramclipseNonScriptParser/*@bgen(jjtree)*/implements FramclipseNonScriptParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/ protected JJTFramclipseNonScriptParserState jjtree = new JJTFramclipseNonScriptParserState(); /*@egen*/ private CharStreamWithOffset charStream = null; public java.util.Collection exceptions = new java.util.ArrayList(); public FramclipseNonScriptParser(String input) { this(new CharStreamWithOffset(new StringReader(input))); } private FramclipseNonScriptParser(CharStreamWithOffset charStream) { this((CharStream)charStream); this.charStream = charStream; } public static void main(String args[]) { String s = "expdef: \n name: urnohorl \n id: horla \n code:~ function kupa(a,b) { yeah \n } \n~\n\n\n"; FramclipseNonScriptParser t = new FramclipseNonScriptParser(s); try { SimpleNode n = t.FramclipseFile(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); //e.printStackTrace(); } } } PARSER_END(FramclipseNonScriptParser) TOKEN_MGR_DECLS : { int blockNestingDepth ; } SKIP : { < "/*"(~["*"])* "*"(~["/"] (~["*"])* "*")* "/" > | <"//"(~["\r","\n"])*["\r"]"\n"> } SKIP : /* WHITE SPACE */ { " " | "\t" | "\r" | "\n" | "\f" } SKIP : /* WHITE SPACE */ { " " | "\t" } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } TOKEN : { < EOL: ("\r")?"\n" > } TOKEN : { : CodeSection } TOKEN : { < MULTI_SECT_START : ":~" > : MultiSect } TOKEN : { : SingleSect } TOKEN : { : GlobalInclude } SKIP : { <"# "(~["\r","\n"])*["\r"]"\n"> } TOKEN : { < INCLUDE_STRING: "\"" ( (~["\"","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\"","_"] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* "\"" > : DEFAULT } TOKEN : { < MULTI_SECT_END : "~" (" ")* ("\r")?"\n" > : DEFAULT } TOKEN : { } TOKEN : { < STRING_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\"","_"] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* "\"" > | < UNTERM_STRING_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\"","_"] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* ["\r"] "\n" > } TOKEN : { < CODE_SECTION_END : "~" (" ")* ("\r")?"\n" > : DEFAULT } TOKEN : { | | /* | | | | | | | | | | | | */ } TOKEN : /* SEPARATORS */ { < LPAREN: "(" > | < RPAREN: ")" > | < LBRACE : "{" > { blockNestingDepth = 1 ; } : Block | "}" | < LBRACKET: "[" > | < RBRACKET: "]" > | < SEMICOLON: ";" > | < COMMA: "," > | < DOT: "." > } TOKEN : /* IDENTIFIERS */ { < IDENT: (|)* > } TOKEN : { < NESTED_LBRACE : "{" > { blockNestingDepth += 1 ; } | < RBRACE : "}" > { blockNestingDepth --; SwitchTo( blockNestingDepth==0 ? CodeSection : Block ) ; } } SKIP : { <~[]> } TOKEN : { < SINGLE_SECT_END : ("\r")?"\n" > : DEFAULT } TOKEN : { < PROP_VALUE : (~["\r","\n"])* > } ASTFramclipseFile FramclipseFile() : {/*@bgen(jjtree) FramclipseFile */ ASTFramclipseFile jjtn000 = new ASTFramclipseFile(JJTFRAMCLIPSEFILE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) FramclipseFile */ try { /*@egen*/ /* FObject() (LOOKAHEAD (()+ FObject()) ()+ FObject())* ()* */ (((FObject()|GlobalInclude()) (|))|)*/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { return jjtn000; }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void FObject() : {/*@bgen(jjtree) FObject */ ASTFObject jjtn000 = new ASTFObject(JJTFOBJECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/ } {/*@bgen(jjtree) FObject */ try { /*@egen*/ {jjtn000.setBeginOffset(charStream.getBeginOffset());} { jjtn000.setClassName(token.image); } (|) (Property() | CodeSection() )*/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getBeginOffset() - 1); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void CodeSection() : {/*@bgen(jjtree) CodeSection */ ASTCodeSection jjtn000 = new ASTCodeSection(JJTCODESECTION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) CodeSection */ try { /*@egen*/ { jjtn000.setBeginOffset(charStream.getBeginOffset()); } (GlobalDecl() | Function() | IncludeStmt())* /*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getBeginOffset()); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void Function() : {/*@bgen(jjtree) Function */ ASTFunction jjtn000 = new ASTFunction(JJTFUNCTION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) Function */ try { /*@egen*/ try{ { jjtn000.setBeginOffset(charStream.getBeginOffset()); } IdentList() [ IdentList() ] (CodeBlock())* } catch(ParseException e) { token_source.SwitchTo(DEFAULT); //error_skipto(new int[] { EOF }); }/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getBeginOffset()); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void GlobalDecl() : {/*@bgen(jjtree) GlobalDecl */ ASTGlobalDecl jjtn000 = new ASTGlobalDecl(JJTGLOBALDECL); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) GlobalDecl */ try { /*@egen*/ { jjtn000.setBeginOffset(charStream.getBeginOffset()); } IdentList() /*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getBeginOffset()); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void IncludeStmt() : {/*@bgen(jjtree) IncludeStmt */ ASTIncludeStmt jjtn000 = new ASTIncludeStmt(JJTINCLUDESTMT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) IncludeStmt */ try { /*@egen*/ { jjtn000.setBeginOffset(charStream.getBeginOffset()); } { jjtn000.setFileName(token.image); }/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getOffset()); }/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void GlobalInclude() : {/*@bgen(jjtree) GlobalInclude */ ASTGlobalInclude jjtn000 = new ASTGlobalInclude(JJTGLOBALINCLUDE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) GlobalInclude */ try { /*@egen*/ { jjtn000.setBeginOffset(charStream.getBeginOffset()); } { jjtn000.setFileName(token.image); }/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getOffset()); }/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void IdentList() : {/*@bgen(jjtree) IdentList */ ASTIdentList jjtn000 = new ASTIdentList(JJTIDENTLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) IdentList */ try { /*@egen*/ { jjtn000.addIdent(token.image); } ( { jjtn000.addIdent(token.image); } )*/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void Property() : {/*@bgen(jjtree) Property */ ASTProperty jjtn000 = new ASTProperty(JJTPROPERTY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) Property */ try { /*@egen*/ { jjtn000.setBeginOffset(charStream.getBeginOffset()); } { jjtn000.setName(token.image); } ( SingleLinePropertyValue()/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getBeginOffset() - 1); } | MultiLinePropertyValue()/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setEndOffset(charStream.getBeginOffset()); } )/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void SingleLinePropertyValue() : {/*@bgen(jjtree) SingleLinePropertyValue */ ASTSingleLinePropertyValue jjtn000 = new ASTSingleLinePropertyValue(JJTSINGLELINEPROPERTYVALUE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) SingleLinePropertyValue */ try { /*@egen*/ { jjtn000.setValue(token.image); } (| )/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void CodeBlock() : {} { (CodeBlock())* } void MultiLinePropertyValue() : {/*@bgen(jjtree) MultiLinePropertyValue */ ASTMultiLinePropertyValue jjtn000 = new ASTMultiLinePropertyValue(JJTMULTILINEPROPERTYVALUE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) MultiLinePropertyValue */ try { /*@egen*/ /*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } JAVACODE void error_skipto(int[] kinds) { //ParseException e = generateParseException(); // generate the exception object. //System.out.println(e.toString()); // print the error message Token t; if(kinds.length > 0) { java.util.Arrays.sort(kinds); do { t = getNextToken(); } while (java.util.Arrays.binarySearch(kinds, t.kind) < 0); } }