From b1e52c7b681a0bc2704509b63a8907b3004901b3 Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Thu, 10 Oct 2013 16:23:32 -0700 Subject: [PATCH] add more to spec-compiler.jj --- grammer/spec-compiler.jj | 193 +++++++++++++++--- .../specExtraction/SpecExtractor.java | 2 - 2 files changed, 170 insertions(+), 25 deletions(-) diff --git a/grammer/spec-compiler.jj b/grammer/spec-compiler.jj index 110dcb9..bfcd6b9 100644 --- a/grammer/spec-compiler.jj +++ b/grammer/spec-compiler.jj @@ -22,8 +22,10 @@ @Begin @Interface: ... @Commit_point_set: - ... + IDENTIFIER | IDENTIFIER ... @Condition: ... (Optional) + @HB_Condition: ... + @HB_Condition: ... @ID: ... (Optional, use default ID) @Check: (Optional) ... @@ -93,18 +95,17 @@ SKIP : "\r\n" | "\t" - /* | // "#" comment for the specification <"#" (~["\n", "\r"])* (["\n", "\r"])> | // "//" comment for the specification <"//" (~["\n", "\r"])* (["\n", "\r"])> - */ } TOKEN : { +/* Above are specification-only tokens */ | @@ -125,7 +126,7 @@ TOKEN : | | - + | | @@ -146,67 +147,194 @@ TOKEN : | + + +/* Specification & C/C++ shared tokens */ | <#DIGIT: ["0"-"9"]> | <#LETTER: ["a"-"z", "A"-"Z"]> | - ( | | "_")*> + | "_") ( | | "_")*> | + +| + | - + +| + | "> | + +| +/* C/C++ only token*/ + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + "> +| + +| + +| + +| + +| + +| + < INTEGER_LITERAL: + (["l","L"])? + | (["l","L"])? + | (["l","L"])?> +| + < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > +| + < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > +| + < #OCTAL_LITERAL: "0" (["0"-"7"])* > +| + < FLOATING_POINT_LITERAL: + + | > +| + < #DECIMAL_FLOATING_POINT_LITERAL: + (["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F","d","D"])? + | "." (["0"-"9"])+ ()? (["f","F","d","D"])? + | (["0"-"9"])+ (["f","F","d","D"])? + | (["0"-"9"])+ ()? ["f","F","d","D"]> +| + < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > +| + < #HEXADECIMAL_FLOATING_POINT_LITERAL: + "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? (["f","F","d","D"])? + | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ (["f","F","d","D"])?> +| + < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ > } void Start() : {} { - //Global_construct() - - // C_CPP_CODE() + ( + LOOKAHEAD(3) Global_construct() | + LOOKAHEAD(3) Interface() | + LOOKAHEAD(3) Potential_commit_point_define() | + LOOKAHEAD(3) Commit_point_define() | + LOOKAHEAD(3) Commit_point_define_check() + ) + } void Global_construct() : -{} +{ +} { - Global_define() (Interface_cluster())? (Happens_before())? + Global_define() (Interface_clusters())? (Happens_before())? } -/* -void C_CPP_CODE() : -{} +String C_CPP_CODE() : { - <(~["@"])+> + StringBuilder text; + Token t; } -*/ +{ + { + text = new StringBuilder(); + t = new Token(); + } + (( + t = | t = | t = | t = | + t = | t = | t = | t = | + t = | t = | t = | t = | t = | t = | t = | + t = | t = | t = | t = | t = | + t = | t = | t = | t = | + t = | t = | t = | + t = | t = + ) + { + text.append(t.image); + text.append("\n"); + } + )+ + { + System.out.println(text); + return text.toString(); + } +} + void Global_define() : {} { - //C_CPP_CODE() + C_CPP_CODE() } void Conditional_interface() : {} { - (<"(" ")">)* + ( )* } void Interface_cluster() : {} { - + Conditional_interface() ( Conditional_interface())* - + } void Interface_clusters() : @@ -224,6 +352,18 @@ void Happens_before() : void Interface() : {} { + + + + ( )* + ( C_CPP_CODE())? + ( C_CPP_CODE())* + ( C_CPP_CODE())? + ( C_CPP_CODE())? + ( C_CPP_CODE())? + ( C_CPP_CODE())? + ( C_CPP_CODE())? + } @@ -231,7 +371,9 @@ void Potential_commit_point_define() : {} { - + + C_CPP_CODE() +