/* spec-compiler.jj Grammer definition for the specification */ /* SPEC constructs: Each construct should be embraced by /DOUBLE_STAR ... STAR/ annotation. Within there, any line beginning with a "#" is a comment of the annotation. Each constrcut should begin with @Begin and end with @End. Otherwise, the annotation would be considered as normal comments of the source. a) Global construct @Begin @Global_define: ... @Interface_cluster: ... @Happens-before: ... @End b) Interface construct @Begin @Interface: ... @Commit_point_set: ... @Condition: ... (Optional) @ID: ... (Optional, use default ID) @Check: (Optional) ... @Action: (Optional) ... @Post_action: (Optional) @Post_check: (Optional) @End c) Potential commit construct @Begin @Potential_commit_point_define: ... @Label: ... @End d) Commit point define construct @Begin @Commit_point_define_check: ... @Label: ... @End OR @Begin @Commit_point_define: ... @Potential_commit_point_label: ... @Label: ... @End */ options { STATIC = false; JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(SpecParser) package edu.uci.eecs.specCompiler.grammerParser; class SpecParser { public static void main(String[] argvs) throws ParseException, TokenMgrError { SpecParser parser = new SpecParser(System.in); parser.Start(); System.out.println("Parsing finished!"); } } PARSER_END(SpecParser) SKIP : { " " | "\n" | "\r" | "\t" | // "#" comment for the specification <"#" (~["\n", "\r"])* (["\n", "\r"])> | // "//" comment for the specification <"//" (~["\n", "\r"])* (["\n", "\r"])> } TOKEN : { | | | | | | | | | | | | | | | | | | | | | <#DIGIT: ["0"-"9"]> | <#NONZERO_DIGIT: ["1"-"9"]> | <#LETTER: ["a"-"z", "A"-"Z"]> | <#NUM: > | ( | | "_")> } void Start() : {} { Global_construct() } void Global_construct() : {} { Global_define() (Interface_cluster())? (Happens_before())? } void C_CPP_CODE() : {} { <(~["@"])+> } void Global_define() : {} { C_CPP_CODE() } void Conditional_interface() : {} { (<"(" ")"> | "") } void Interface_cluster() : {} { "=" "{" Conditional_interface() (",," Conditional_interface())* "}" } void Interface_clusters() : {} { (Interface_cluster())+ } void Happens_before() : {} { (Conditional_interface() "->" Conditional_interface())+ } void Interface() : {} { "(" ")" "->" } void Potential_commit_point_define() : {} { "(" ")" "->" } void Commit_point_define() : {} { "(" ")" "->" } void Commit_point_define_check() : {} { "(" ")" "->" }