1 /* spec-compiler.jj Grammer definition for the specification */
6 Each construct should be embraced by /DOUBLE_STAR ... STAR/ annotation.
7 Within there, any line beginning with a "#" is a comment of the annotation.
8 Each constrcut should begin with @Begin and end with @End. Otherwise, the
9 annotation would be considered as normal comments of the source.
21 b) Interface construct
26 @Condition: ... (Optional)
27 @ID: ... (Optional, use default ID)
32 @Post_action: (Optional)
33 @Post_check: (Optional)
36 c) Potential commit construct
38 @Potential_commit_point_define: ...
42 d) Commit point define construct
44 @Commit_point_define_check: ...
51 @Commit_point_define: ...
52 @Potential_commit_point_label: ...
61 JAVA_UNICODE_ESCAPE = true;
64 PARSER_BEGIN(SpecParser)
65 package edu.uci.eecs.specCompiler.grammerParser;
67 import java.io.FileInputStream;
68 import java.io.FileNotFoundException;
71 public static void main(String[] argvs)
72 throws ParseException, TokenMgrError {
74 FileInputStream fis = new FileInputStream("./grammer/spec.txt");
75 SpecParser parser = new SpecParser(fis);
77 System.out.println("Parsing finished!");
78 } catch (FileNotFoundException e) {
83 PARSER_END(SpecParser)
98 // "#" comment for the specification
99 <"#" (~["\n", "\r"])* (["\n", "\r"])>
101 // "//" comment for the specification
102 <"//" (~["\n", "\r"])* (["\n", "\r"])>
116 <GLOBAL_DEFINE: "@Global_define:">
118 <INTERFACE_CLUSTER: "@Interface_cluster:">
120 <HAPPENS_BEFORE: "@Happens_before:">
122 <INTERFACE: "@Interface:">
124 <COMMIT_POINT_SET: "@Commit_point_set:">
126 <CONDITION: "@Condition:">
128 <HB_CONDITIONS: "@HB_condition:">
136 <POST_ACTION: "@Post_action:">
138 <POST_CHECK: "@Post_check:">
140 <POTENTIAL_COMMIT_POINT_DEFINE: "@Potential_commit_point_define:">
144 <COMMIT_POINT_DEFINE_CHECK: "@Commit_point_define_check:">
146 <COMMIT_POINT_DEFINE: "@Commit_point_define:">
148 <POTENTIAL_COMMIT_POINT_LABEL: "@Potential_commit_point_label:">
152 <#LETTER: ["a"-"z", "A"-"Z"]>
154 <IDENTIFIER: <LETTER> (<LETTER> | <DIGIT> | "_")*>
170 //Global_construct() <EOF>
172 //<IDENTIFIER> C_CPP_CODE() <EOF>
175 void Global_construct() :
180 Global_define() (Interface_cluster())? (Happens_before())?
192 void Global_define() :
195 <GLOBAL_DEFINE> //C_CPP_CODE()
198 void Conditional_interface() :
201 <IDENTIFIER> (<"(" <IDENTIFIER> ")">)*
204 void Interface_cluster() :
207 <IDENTIFIER> <EQUALS> <LEFT_PARAN>
208 Conditional_interface() (<COMMA> Conditional_interface())*
212 void Interface_clusters() :
215 <INTERFACE_CLUSTER> (Interface_cluster())+
218 void Happens_before() :
221 <HAPPENS_BEFORE> (Conditional_interface() <HB_SYMBOL> Conditional_interface())+
230 void Potential_commit_point_define() :
240 void Commit_point_define() :
250 void Commit_point_define_check() :