SpecExtractor.java seems to work
[cdsspec-compiler.git] / grammer / spec-compiler.jj
index 6ce4495..f7a4248 100644 (file)
@@ -64,12 +64,20 @@ options {
 PARSER_BEGIN(SpecParser)
 package edu.uci.eecs.specCompiler.grammerParser;
 
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
        class SpecParser {
                public static void main(String[] argvs)
                throws ParseException, TokenMgrError {
-                       SpecParser parser = new SpecParser(System.in);
-                       parser.Start();
-                       System.out.println("Parsing finished!");
+                       try {
+                               FileInputStream fis = new FileInputStream("./grammer/spec.txt");
+                               SpecParser parser = new SpecParser(fis);
+                               parser.Start();
+                               System.out.println("Parsing finished!");
+                       } catch (FileNotFoundException e) {
+                               e.printStackTrace();
+                       }
                }
        }
 PARSER_END(SpecParser)
@@ -81,14 +89,18 @@ SKIP :
        "\n"
 |
        "\r"
+|
+       "\r\n"
 |
        "\t"
+       /*
 |
        // "#" comment for the specification
        <"#" (~["\n", "\r"])* (["\n", "\r"])>
 |
        // "//" comment for the specification
        <"//" (~["\n", "\r"])* (["\n", "\r"])>
+       */
 }
 
 TOKEN :
@@ -136,12 +148,8 @@ TOKEN :
        <POTENTIAL_COMMIT_POINT_LABEL: "@Potential_commit_point_label:">
 |
        <#DIGIT: ["0"-"9"]>
-|
-       <#NONZERO_DIGIT: ["1"-"9"]>
 |
        <#LETTER: ["a"-"z", "A"-"Z"]>
-|
-       <#NUM: <NONZERO_DIGIT> <DIGIT>>
 |
        <IDENTIFIER: <LETTER> (<LETTER> | <DIGIT> | "_")>       
 }
@@ -149,7 +157,9 @@ TOKEN :
 void Start() :
 {}
 {
-       Global_construct() <EOF>
+       //Global_construct() <EOF>
+       <EOF>
+       //<IDENTIFIER> <EOF>
 }
 
 void Global_construct() :
@@ -157,13 +167,13 @@ void Global_construct() :
 {
        <HEAD>
                <BEGIN> 
-                       Global_define() (Interface_cluster())? (Happens_before())?
+                       //Global_define() (Interface_cluster())? (Happens_before())?
                <END>
        <TAIL>
 }
 
 void C_CPP_CODE() :
-{}
+{String code;}
 {
        <(~["@"])+>
 }
@@ -201,10 +211,6 @@ void Happens_before() :
 void Interface() :
 {}
 {
-       <HEAD> 
-               <BEGIN> 
-                       <HAPPENS_BEFORE> <IDENTIFIER> "(" <IDENTIFIER> ")"  "->" <IDENTIFIER>
-               <END>
        <TAIL>
 }
 
@@ -213,7 +219,6 @@ void Potential_commit_point_define() :
 {
        <HEAD> 
                <BEGIN> 
-                       <HAPPENS_BEFORE> <IDENTIFIER> "(" <IDENTIFIER> ")"  "->" <IDENTIFIER>
                <END>
        <TAIL>
 }
@@ -224,7 +229,6 @@ void Commit_point_define() :
 {
        <HEAD> 
                <BEGIN> 
-                       <HAPPENS_BEFORE> <IDENTIFIER> "(" <IDENTIFIER> ")"  "->" <IDENTIFIER>
                <END>
        <TAIL>
 }
@@ -235,7 +239,6 @@ void Commit_point_define_check() :
 {
        <HEAD> 
                <BEGIN> 
-                       <HAPPENS_BEFORE> <IDENTIFIER> "(" <IDENTIFIER> ")"  "->" <IDENTIFIER>
                <END>
        <TAIL>
 }