diff --git a/Parser/spec/Fortran2008.rats b/Parser/spec/Fortran2008.rats index c2571b7c2bbcd1d0f3aa789ff315ef0a14d17570..0100965ca3d19752580dd0562dbb81335ff87694 100644 --- a/Parser/spec/Fortran2008.rats +++ b/Parser/spec/Fortran2008.rats @@ -507,6 +507,7 @@ Keyword keyword = //// // R303 //// Name ::= <String> ; Name name = +<BEGINNING> n:LETTERS SS { yyValue = new Name(n); @@ -1665,9 +1666,9 @@ AcImpliedDo ac_implied_do_rest = ; //// // R474 -//// AcImpliedDoControl ::= DoVariable Lower:Expr Upper:Expr [Step:Expr] ; +//// AcImpliedDoControl ::= Name Lower:Expr Upper:Expr [Step:Expr] ; AcImpliedDoControl ac_implied_do_control = - v:do_variable EQUALS r1:expr COMMA r2:expr s:(COMMA expr)? + v:name EQUALS r1:expr COMMA r2:expr s:(COMMA expr)? { Opt<Expr> s_opt = (s==null) ? new Opt<Expr>() : new Opt<Expr>(s); yyValue = new AcImpliedDoControl(v, r1, r2, s_opt); @@ -2204,7 +2205,7 @@ DataStmtObject data_stmt_object = ; //// // R537 -//// DataImpliedDo ::= DataIDoObject* DataIDoVariable Lower:Expr Upper:Expr [Step:Expr] ; +//// DataImpliedDo ::= DataIDoObject* Name Lower:Expr Upper:Expr [Step:Expr] ; DataImpliedDo data_implied_do = LPAREN r:data_implied_do_rest { @@ -2212,7 +2213,7 @@ DataImpliedDo data_implied_do = } ; DataImpliedDo data_implied_do_rest = - v:data_i_do_variable EQUALS l:expr COMMA u:expr s:(COMMA yyValue:expr)? RPAREN + v:name EQUALS l:expr COMMA u:expr s:(COMMA yyValue:expr)? RPAREN { Opt<Expr> s_opt = (s==null) ? new Opt<Expr>() : new Opt<Expr>(s); yyValue = new DataImpliedDo(new List(), v, l, u, s_opt); @@ -2246,13 +2247,7 @@ DataIDoObject data_i_do_object = ; //// // R539 -//// DataIDoVariable ::= DoVariable ; -DataIDoVariable data_i_do_variable = - d:do_variable - { - yyValue = new DataIDoVariable(d); - } -; +//// // SIMPLIFY: rule omitted and occurrences replaced by Name //// // R540 //// DataStmtValue ::= [DataStmtRepeat] DataStmtConstant ; @@ -4706,7 +4701,7 @@ DoWhileStmt do_while_stmt = //// // R818 //// abstract LoopControl ; -//// SimpleLoopControl:LoopControl ::= DoVariable Lower:Expr Upper:Expr [Step:Expr] ; +//// SimpleLoopControl:LoopControl ::= Name Lower:Expr Upper:Expr [Step:Expr] ; //// WhileLoopControl:LoopControl ::= Expr ; //// ConcurrentLoopControl:LoopControl ::= ForallHeader ; LoopControl loop_control = @@ -4715,7 +4710,7 @@ LoopControl loop_control = / concurrent_loop_control ; SimpleLoopControl simple_loop_control = - (COMMA)? v:do_variable EQUALS l:expr COMMA u:expr s:(COMMA yyValue:expr)? + (COMMA)? v:name EQUALS l:expr COMMA u:expr s:(COMMA yyValue:expr)? { Opt<Expr> s_opt = (s==null) ? new Opt<Expr>() : new Opt<Expr>(s); yyValue = new SimpleLoopControl(v, l, u, s_opt); @@ -4735,13 +4730,7 @@ ConcurrentLoopControl concurrent_loop_control = ; //// // R819 -//// DoVariable ::= Name ; -DoVariable do_variable = - n:name - { - yyValue = new DoVariable(n); - } -; +//// // SIMPLIFY: rule omitted and occurrences replaced by Name //// // R820 //// DoBlock ::= Block ; @@ -5604,9 +5593,9 @@ InputOutputItem input_output_item = ; //// // R920 -//// IoImpliedDoControl ::= DoVariable Lower:Expr Upper:Expr [Step:Expr] ; +//// IoImpliedDoControl ::= Name Lower:Expr Upper:Expr [Step:Expr] ; IoImpliedDoControl io_implied_do_control = - v:do_variable EQUALS l:expr COMMA u:expr s:(COMMA yyValue:expr)? + v:name EQUALS l:expr COMMA u:expr s:(COMMA yyValue:expr)? { Opt<Expr> s_opt = (s==null) ? new Opt<Expr>() : new Opt<Expr>(s); yyValue = new IoImpliedDoControl(v,l,u,s_opt); diff --git a/Parser/spec/Printing.jadd b/Parser/spec/Printing.jadd index 7cd96415c1c729e3f688cd88cb35c39b6cc07199..15b9067b841e12334d9c4d04ba40e58b1c8b45bf 100644 --- a/Parser/spec/Printing.jadd +++ b/Parser/spec/Printing.jadd @@ -1027,9 +1027,9 @@ class PrettyPrint { } // R474 - // AcImpliedDoControl ::= DoVariable Lower:Expr Upper:Expr [Step:Expr] ; + // AcImpliedDoControl ::= Name Lower:Expr Upper:Expr [Step:Expr] ; public void AcImpliedDoControl.prettyPrint(PrettyPrinter s) { - getDoVariable().prettyPrint(s); + getName().prettyPrint(s); s.append("="); getLower().prettyPrint(s); s.append(","); @@ -1498,12 +1498,12 @@ class PrettyPrint { } // R537 - // DataImpliedDo ::= DataIDoObject* DataIDoVariable Lower:Expr Upper:Expr [Step:Expr] ; + // DataImpliedDo ::= DataIDoObject* Name Lower:Expr Upper:Expr [Step:Expr] ; public void DataImpliedDo.prettyPrint(PrettyPrinter s) { s.append("("); getDataIDoObjectList().prettyPrintJoin(s, ", "); s.append(","); - getDataIDoVariable().prettyPrint(s); + getName().prettyPrint(s); s.append("="); getLower().prettyPrint(s); s.append(","); @@ -1530,12 +1530,6 @@ class PrettyPrint { getDataImpliedDo().prettyPrint(s); } - // R539 - // DataIDoVariable ::= DoVariable ; - public void DataIDoVariable.prettyPrint(PrettyPrinter s) { - getDoVariable().prettyPrint(s); - } - // R540 // DataStmtValue ::= [DataStmtRepeat] DataStmtConstant ; public void DataStmtValue.prettyPrint(PrettyPrinter s) { @@ -2968,7 +2962,7 @@ class PrettyPrint { // R818 public void SimpleLoopControl.prettyPrint(PrettyPrinter s) { - getDoVariable().prettyPrint(s); + getName().prettyPrint(s); s.append(" = "); getLower().prettyPrint(s); s.append(","); @@ -2988,11 +2982,6 @@ class PrettyPrint { getForallHeader().prettyPrint(s); } - // R819 - public void DoVariable.prettyPrint(PrettyPrinter s) { - getName().prettyPrint(s); - } - // R820 public void DoBlock.prettyPrint(PrettyPrinter s) { getBlock().prettyPrint(s); @@ -3431,7 +3420,7 @@ class PrettyPrint { } // R920 - // IoImpliedDoControl ::= DoVariable Lower:Expr Upper:Expr [Step:Expr] ; + // IoImpliedDoControl ::= Name Lower:Expr Upper:Expr [Step:Expr] ; public void IoImpliedDoControl.prettyPrint(PrettyPrinter s) { getLower().prettyPrint(s); s.append(","); diff --git a/Parser/spec/SlotPrinting.jadd b/Parser/spec/SlotPrinting.jadd index 00248a1723971b268e0df62aadb82c9365d7780d..cbb7af883a1e671edc2043365981b513f02cb3ea 100644 --- a/Parser/spec/SlotPrinting.jadd +++ b/Parser/spec/SlotPrinting.jadd @@ -29,5 +29,10 @@ aspect Printing { public void SlotExecutableConstruct.prettyPrint(PrettyPrinter s) { getExecutableConstructSlot().prettyPrint(s); + s.lb(); + } + + public void SlotForName.prettyPrint(PrettyPrinter s) { + getNameSlot().prettyPrint(s); } } \ No newline at end of file diff --git a/Parser/spec/SlottableFortranParser.rats b/Parser/spec/SlottableFortranParser.rats index cabc561ae7cfc4d6cc4de78d9eab131fe5671ced..b963d6b014f0ee59ac53b91c46aac9752f7ea540 100644 --- a/Parser/spec/SlottableFortranParser.rats +++ b/Parser/spec/SlottableFortranParser.rats @@ -88,6 +88,7 @@ body { // lift invisibility of potential fragments to public public Expr expr := ... ; public ExecutableConstruct executable_construct := ... ; +public Name name := ... ; // == Slots ==================================================================== @@ -156,7 +157,7 @@ IntLiteralConstant int_literal_constant += //// IntLiteralConstantSlot:Slot ; IntLiteralConstantSlot int_literal_constant_slot = - NUMBERSIGN n:slot_name NUMBERSIGN + NUMBERSIGN n:slot_name NUMBERSIGN SS { yyValue = new IntLiteralConstantSlot(n); } @@ -175,10 +176,28 @@ ExecutableConstruct executable_construct += //// ExecutableConstructSlot:Slot ; ExecutableConstructSlot executable_construct_slot = - NUMBERSIGN n:slot_name NUMBERSIGN + NUMBERSIGN n:slot_name NUMBERSIGN LB { yyValue = new ExecutableConstructSlot(n); } ; +// == Name Slots =================================================== + +//// SlotForName:Name ::= NameSlot ; +Name name += + <NameSlot> s:name_slot + { + yyValue = new SlotForName("", s); + } +/ <BEGINNING> ... +; + +//// NameSlot:Slot ; +NameSlot name_slot = + NUMBERSIGN n:slot_name NUMBERSIGN SS + { + yyValue = new NameSlot(n); + } +; diff --git a/Parser/test-data/slots/name.f b/Parser/test-data/slots/name.f new file mode 100644 index 0000000000000000000000000000000000000000..ccf3dce5b8e59ad273af7fa1aa97c45c25c325e8 --- /dev/null +++ b/Parser/test-data/slots/name.f @@ -0,0 +1,7 @@ +! NameSlot + + do #testname# = 0,p + s = s + 2 / h * L(i,j) * T_star(j,k) + end do + +end program diff --git a/Parser/test/org/tud/forty/test/SlotTest.java b/Parser/test/org/tud/forty/test/SlotTest.java index da2d5a9123c20e1edda457a49687255e630d59f9..ccf9d0dd1e2ad6a2d23d91a4982c32f58f5aadcb 100644 --- a/Parser/test/org/tud/forty/test/SlotTest.java +++ b/Parser/test/org/tud/forty/test/SlotTest.java @@ -33,4 +33,9 @@ public class SlotTest extends TestBase { public void testSlotsEquality(File f) throws Exception { testParse(f, false, false, true, false, Root.class); } + + @Test(dataProvider = "Slots") + public void testSlotsName(File f) throws Exception { + testParse(f, false, false, true, false, Root.class); + } } diff --git a/Parser/tools/jastadd/jastadd2.jar b/Parser/tools/jastadd/jastadd2.jar index 25a6603f4bd7e61a05155692850043e1ce0ed7bc..58bdd88b03c47fa67707a7864046451985450609 100644 Binary files a/Parser/tools/jastadd/jastadd2.jar and b/Parser/tools/jastadd/jastadd2.jar differ