a) Global construct
@Begin
+ @Options:
+ # If LANG is not define, it's C++ by default. C does not support class
+ # and template, so if it's defined as C, we should also have a explicit
+ # entry point.
+ LANG = C;
@Global_define:
@DeclareVar:
@InitVar:
@Potential_commit_point_label: ...
@Label: ...
@End
+
+ e) Entry point construct
+ @Begin
+ @Entry_point
+ @End
+
+ f) Interface define construct
+ @Begin
+ @Interface_define: <Interface_Name>
+ @End
*/
import edu.uci.eecs.specCompiler.specExtraction.ActionSubConstruct;
import edu.uci.eecs.specCompiler.specExtraction.ActionSubConstruct.DefineVar;
import edu.uci.eecs.specCompiler.specExtraction.SequentialDefineSubConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.InterfaceDefineConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.EntryPointConstruct;
public class SpecParser {
public static void main(String[] argvs)
<BEGIN: "@Begin">
|
<END: "@End">
+|
+ <OPTIONS: "@Options:">
|
<GLOBAL_DEFINE: "@Global_define:">
|
<INTERFACE: "@Interface:">
|
<COMMIT_POINT_SET: "@Commit_point_set:">
+|
+ <ENTRY_POINT: "@Entry_point">
+|
+ <INTERFACE_DEFINE: "@Interface_define:">
|
<CONDITION: "@Condition:">
|
LOOKAHEAD(3) res = Interface() |
LOOKAHEAD(3) res = Potential_commit_point_define() |
LOOKAHEAD(3) res = Commit_point_define() |
- LOOKAHEAD(3) res = Commit_point_define_check()
+ LOOKAHEAD(3) res = Commit_point_define_check() |
+ LOOKAHEAD(3) res = Entry_point() |
+ LOOKAHEAD(3) res = Interface_define()
)
<EOF>
{
{
GlobalConstruct res;
SequentialDefineSubConstruct code;
+ HashMap<String, String> options;
+ String key, value;
}
{
- { res = null; }
+ {
+ res = null;
+ options = new HashMap<String, String>();
+ }
<HEAD>
<BEGIN>
+ (<OPTIONS>
+ ((key = <IDENTIFIER>.image)
+ <EQUALS>
+ (value = <IDENTIFIER>.image)
+ {
+ if (options.containsKey(key)) {
+ throw new ParseException("Duplicate options!");
+ }
+ options.put(key, value);
+ }
+ <SEMI_COLON>
+ )*
+ )?
(code = Global_define())
- { res = new GlobalConstruct(code); }
+ { res = new GlobalConstruct(code, options); }
(Interface_clusters(res))?
(Happens_before(res))?
<END>
initVar = "";
defineFunc = "";
}
- <GLOBAL_DEFINE>
- (<DECLARE_VAR> (declareVar = C_CPP_CODE()))?
+ <GLOBAL_DEFINE>
+ (<DECLARE_VAR> (declareVar = C_CPP_CODE()))?
(<INIT_VAR> (initVar = C_CPP_CODE()))?
(<DEFINE_FUNC> (defineFunc = C_CPP_CODE()))?
{
return res;
}
}
+
+EntryPointConstruct Entry_point() :
+{}
+{
+
+ <HEAD>
+ <BEGIN>
+ <ENTRY_POINT>
+ <END>
+ <TAIL>
+ {
+ return new EntryPointConstruct();
+ }
+}
+
+InterfaceDefineConstruct Interface_define() :
+{
+ String name;
+}
+{
+ <HEAD>
+ <BEGIN>
+ <INTERFACE_DEFINE> (name = <IDENTIFIER>.image)
+ <END>
+ <TAIL>
+ {
+ return new InterfaceDefineConstruct(name);
+ }
+}
+
+