XRM 22: Fix literals' and identifiers' constructions.

https://svn.lrde.epita.fr/svn/xrm/trunk Index: ChangeLog from SIGOURE Benoit <sigoure.benoit@lrde.epita.fr> Fix literals' and identifiers' constructions. The Int, Double and Identifier nodes were constructed only when they appeared within Expression nodes. This commit fixes this. * src/syn/prism/PRISM-Literals.sdf: Always construct AST nodes for literals (Int and Double)... * src/syn/prism/PRISM-Identifier.sdf: ... and for Identifiers. * src/syn/prism/PRISM-Expression.sdf: Remove constructions. * src/lib/xrm/pp/xrm-module.str: Change the boxing rules accordingly. * src/lib/xrm/pp/xrm-staticfor.str, * src/lib/prism/pp/prism-update.str, * src/lib/prism/pp/prism-reward.str, * src/lib/prism/pp/prism-module.str, * src/lib/prism/pp/prism-declaration.str, * src/lib/prism/pp/prism-constant.str, * src/lib/prism/pp/prism-expression.str, * src/lib/prism/pp/prism-formula.str, * src/lib/prism/pp/prism-systemcomposition.str, * src/lib/prism/pp/prism-command.str: Likewise. * vcs/xrm.rb: Change the mailing list to projects@lrde.epita.fr. src/lib/prism/pp/prism-command.str | 4 +-- src/lib/prism/pp/prism-constant.str | 24 +++++++++--------- src/lib/prism/pp/prism-declaration.str | 14 +++++----- src/lib/prism/pp/prism-expression.str | 4 +-- src/lib/prism/pp/prism-formula.str | 2 - src/lib/prism/pp/prism-module.str | 10 +++---- src/lib/prism/pp/prism-reward.str | 4 +-- src/lib/prism/pp/prism-systemcomposition.str | 4 +-- src/lib/prism/pp/prism-update.str | 4 +-- src/lib/xrm/pp/xrm-module.str | 4 +-- src/lib/xrm/pp/xrm-staticfor.str | 36 +++++++++++++-------------- src/syn/prism/PRISM-Expression.sdf | 6 ++-- src/syn/prism/PRISM-Identifier.sdf | 2 - src/syn/prism/PRISM-Literals.sdf | 15 +++++++---- vcs/xrm.rb | 2 - 15 files changed, 70 insertions(+), 65 deletions(-) Index: src/lib/xrm/pp/xrm-module.str --- src/lib/xrm/pp/xrm-module.str (revision 21) +++ src/lib/xrm/pp/xrm-module.str (working copy) @@ -4,8 +4,8 @@ // "module" Identifier DeclarationOrCommand* "endmodule" -> Module prism-to-box: - Module(s, dec-or-cmd-list) - -> box |[ V[ V is=2 [ H hs=1 [KW["module"] s ] + Module(idf, dec-or-cmd-list) + -> box |[ V[ V is=2 [ H hs=1 [KW["module"] ~idf ] ~*dec-or-cmd-list ] KW["endmodule"] Index: src/lib/xrm/pp/xrm-staticfor.str --- src/lib/xrm/pp/xrm-staticfor.str (revision 21) +++ src/lib/xrm/pp/xrm-staticfor.str (working copy) @@ -5,11 +5,11 @@ // "for" Identifier "from" Int "to" Int "do" ModulesFileSection+ "end" // -> OuterStaticFor prism-to-box: - OuterStaticFor(s, for-from, for-to, mfs-list) + OuterStaticFor(idf, for-from, for-to, mfs-list) -> box |[ V[ V is=2 [ - H hs=1 [ KW["for"] s - KW["from"] NUM[~lit:for-from] - KW["to"] NUM[~lit:for-to] KW["do"] ] + H hs=1 [ KW["for"] ~idf + KW["from"] ~for-from + KW["to"] ~for-to KW["do"] ] ~*mfs-list // in the innermost V box ] KW["end"] // in the outermost V box ] ]| @@ -17,12 +17,12 @@ // "for" Identifier "from" Int "to" Int "step" Int "do" // ModulesFileSection+ "end" -> OuterStaticFor prism-to-box: - OuterStaticFor(s, for-from, for-to, for-step, mfs-list) + OuterStaticFor(idf, for-from, for-to, for-step, mfs-list) -> box |[ V[ V is=2 [ - H hs=1 [ KW["for"] s - KW["from"] NUM[~lit:for-from] - KW["to"] NUM[~lit:for-to] - KW["step"] NUM[~lit:for-step] KW["do"] ] + H hs=1 [ KW["for"] ~idf + KW["from"] ~for-from + KW["to"] ~for-to + KW["step"] ~for-step KW["do"] ] ~*mfs-list // in the innermost V box ] KW["end"] // in the outermost V box ] ]| @@ -30,11 +30,11 @@ // "for" Identifier "from" Int "to" Int "do" DeclarationOrCommand+ "end" // -> InnerStaticFor prism-to-box: - InnerStaticFor(s, for-from, for-to, dec-or-cmd-list) + InnerStaticFor(idf, for-from, for-to, dec-or-cmd-list) -> box |[ V[ V is=2 [ - H hs=1 [ KW["for"] s - KW["from"] NUM[~lit:for-from] - KW["to"] NUM[~lit:for-to] KW["do"] ] + H hs=1 [ KW["for"] ~idf + KW["from"] ~for-from + KW["to"] ~for-to KW["do"] ] ~*dec-or-cmd-list // in the innermost V box ] KW["end"] // in the outermost V box ] ]| @@ -42,12 +42,12 @@ // "for" Identifier "from" Int "to" Int "step" Int "do" // DeclarationOrCommand+ "end" -> InnerStaticFor prism-to-box: - InnerStaticFor(s, for-from, for-to, for-step, dec-or-cmd-list) + InnerStaticFor(idf, for-from, for-to, for-step, dec-or-cmd-list) -> box |[ V[ V is=2 [ - H hs=1 [ KW["for"] s - KW["from"] NUM[~lit:for-from] - KW["to"] NUM[~lit:for-to] - KW["step"] NUM[~lit:for-step] KW["do"] ] + H hs=1 [ KW["for"] ~idf + KW["from"] ~for-from + KW["to"] ~for-to + KW["step"] ~for-step KW["do"] ] ~*dec-or-cmd-list // in the innermost V box ] KW["end"] // in the outermost V box ] ]| Index: src/lib/prism/pp/prism-update.str --- src/lib/prism/pp/prism-update.str (revision 21) +++ src/lib/prism/pp/prism-update.str (working copy) @@ -28,5 +28,5 @@ -> H hs=0 [ "(" ~idf-prime "=" ~exp ")" ] prism-to-box: - IdentifierPrime(s) -> box |[ s2 ]| - where <conc-strings> (s, "'") => s2 + IdentifierPrime(idf) -> box |[ VAR[~lit:idf-primed] ]| + where <conc-strings> (idf, "'") => idf-primed Index: src/lib/prism/pp/prism-reward.str --- src/lib/prism/pp/prism-reward.str (revision 21) +++ src/lib/prism/pp/prism-reward.str (working copy) @@ -10,8 +10,8 @@ // "[" Identifier? "]" Expression ":" Expression ";" -> RewardStructItem prism-to-box: - RewardStructItem(Some(s), exp1, exp2) - -> H hs=1 [ H hs=0 ["[" s "]"] ~exp1 ":" H hs=0 [~exp2 ";"] ] + RewardStructItem(Some(idf), exp1, exp2) + -> H hs=1 [ H hs=0 ["[" ~idf "]"] ~exp1 ":" H hs=0 [~exp2 ";"] ] prism-to-box: RewardStructItem(None(), exp1, exp2) Index: src/lib/prism/pp/prism-module.str --- src/lib/prism/pp/prism-module.str (revision 21) +++ src/lib/prism/pp/prism-module.str (working copy) @@ -5,8 +5,8 @@ // "module" Identifier Declaration* Command* "endmodule" -> Module prism-to-box: - Module(s, dec-list, cmd-list) - -> box |[ V[ V is=2 [ H hs=1 [KW["module"] s ] + Module(idf, dec-list, cmd-list) + -> box |[ V[ V is=2 [ H hs=1 [KW["module"] ~idf ] ~*dec-list ~*cmd-list ] @@ -16,8 +16,8 @@ // "module" Identifier "=" Identifier "[" Renames "]" "endmodule" // -> RenamedModule prism-to-box: - RenamedModule(s1, s2, renames) - -> H hs=1 [KW["module"] s1 "=" s2 "[" ~renames "]" KW["endmodule"]] + RenamedModule(idf1, idf2, renames) + -> H hs=1 [KW["module"] ~idf1 "=" ~idf2 "[" ~renames "]" KW["endmodule"]] // {Rename ","}+ -> Renames prism-to-box: @@ -26,4 +26,4 @@ // Identifier "=" Identifier -> Rename prism-to-box: - Rename(s1, s2) -> H hs=0 [ s1 "=" s2 ] + Rename(idf1, idf2) -> H hs=0 [ ~idf1 "=" ~idf2 ] Index: src/lib/prism/pp/prism-declaration.str --- src/lib/prism/pp/prism-declaration.str (revision 21) +++ src/lib/prism/pp/prism-declaration.str (working copy) @@ -4,22 +4,22 @@ // Identifier ":" "[" Expression ".." Expression "]" ";" -> IntDecNoInit prism-to-box: - IntDecNoInit(s, range-start, range-end) - -> H hs=1 [ s ":" H hs=0["[" ~range-start ".." ~range-end "]" ";"] ] + IntDecNoInit(idf, range-start, range-end) + -> H hs=1 [ ~idf ":" H hs=0["[" ~range-start ".." ~range-end "]" ";"] ] // Identifier ":" "[" Expression ".." Expression "]" "init" Expression ";" // -> IntDec prism-to-box: - IntDec(s, range-start, range-end, exp-init) - -> H hs=1 [ s ":" H hs=0 ["[" ~range-start ".." ~range-end "]"] + IntDec(idf, range-start, range-end, exp-init) + -> H hs=1 [ ~idf ":" H hs=0 ["[" ~range-start ".." ~range-end "]"] KW["init"] H hs=0[~exp-init ";"] ] // Identifier ":" "bool" ";" -> BoolDecNoInit prism-to-box: - BoolDecNoInit(s) -> H hs=1 [ s ":" H hs=0 [KW["bool"] ";"] ] + BoolDecNoInit(idf) -> H hs=1 [ ~idf ":" H hs=0 [KW["bool"] ";"] ] // Identifier ":" "bool" "init" Expression ";" -> BoolDec prism-to-box: - BoolDec(s, exp-init) - -> H hs=1 [ s ":" KW["bool"] KW["init"] H hs=0 [~exp-init ";"] ] + BoolDec(idf, exp-init) + -> H hs=1 [ ~idf ":" KW["bool"] KW["init"] H hs=0 [~exp-init ";"] ] Index: src/lib/prism/pp/prism-constant.str --- src/lib/prism/pp/prism-constant.str (revision 21) +++ src/lib/prism/pp/prism-constant.str (working copy) @@ -4,30 +4,30 @@ // "const" "int" Identifier "=" Expression ";" -> ConstInt prism-to-box: - ConstInt(s, exp) - -> H hs=1 [ KW["const"] KW["int"] s "=" H hs=0 [~exp ";"] ] + ConstInt(idf, exp) + -> H hs=1 [ KW["const"] KW["int"] ~idf "=" H hs=0 [~exp ";"] ] // "const" "int" Identifier ";" -> ConstIntNoInit prism-to-box: - ConstIntNoInit(s) - -> H hs=1 [ KW["const"] KW["int"] H hs=0 [s ";"] ] + ConstIntNoInit(idf) + -> H hs=1 [ KW["const"] KW["int"] H hs=0 [~idf ";"] ] // "const" "double" Identifier "=" Expression ";" -> ConstDouble prism-to-box: - ConstDouble(s, exp) - -> H hs=1 [ KW["const"] KW["double"] s "=" H hs=0[~exp ";"] ] + ConstDouble(idf, exp) + -> H hs=1 [ KW["const"] KW["double"] ~idf "=" H hs=0 [~exp ";"] ] // "const" "double" Identifier ";" -> ConstDoubleNoInit prism-to-box: - ConstDoubleNoInit(s) - -> H hs=1 [ KW["const"] KW["double"] H hs=0[s ";"] ] + ConstDoubleNoInit(idf) + -> H hs=1 [ KW["const"] KW["double"] H hs=0 [~idf ";"] ] // "const" "bool" Identifier "=" Expression ";" -> ConstBool prism-to-box: - ConstBool(s, exp) - -> H hs=1 [ KW["const"] KW["bool"] s "=" H hs=0[~exp ";"] ] + ConstBool(idf, exp) + -> H hs=1 [ KW["const"] KW["bool"] ~idf "=" H hs=0 [~exp ";"] ] // "const" "bool" Identifier ";" -> ConstBoolNoInit prism-to-box: - ConstBoolNoInit(s) - -> H hs=1 [ KW["const"] KW["bool"] H hs=0[s ";"] ] + ConstBoolNoInit(idf) + -> H hs=1 [ KW["const"] KW["bool"] H hs=0 [~idf ";"] ] Index: src/lib/prism/pp/prism-expression.str --- src/lib/prism/pp/prism-expression.str (revision 21) +++ src/lib/prism/pp/prism-expression.str (working copy) @@ -95,8 +95,8 @@ where <implode-list(|",")> args => args-imploded prism-to-box: - Call(s, args) - -> box |[ H hs=0 [ "func" "(" H hs=1 [ H hs=0[s ","] + Call(idf, args) + -> box |[ H hs=0 [ "func" "(" H hs=1 [ H hs=0[~idf ","] ~args-imploded ] ")" ] ]| where <implode-list(|",")> args => args-imploded Index: src/lib/prism/pp/prism-formula.str --- src/lib/prism/pp/prism-formula.str (revision 21) +++ src/lib/prism/pp/prism-formula.str (working copy) @@ -4,4 +4,4 @@ // "formula" Identifier "=" Expression ";" -> FormulaDef prism-to-box: - FormulaDef(s, exp) -> H hs=1 [ KW["formula"] s "=" H hs=0 [~exp ";"] ] + FormulaDef(idf, exp) -> H hs=1 [ KW["formula"] ~idf "=" H hs=0 [~exp ";"] ] Index: src/lib/prism/pp/prism-systemcomposition.str --- src/lib/prism/pp/prism-systemcomposition.str (revision 21) +++ src/lib/prism/pp/prism-systemcomposition.str (working copy) @@ -50,11 +50,11 @@ // Identifier -> SystemAction prism-to-box: - SystemAction(s) -> s + SystemAction(idf) -> idf // Identifier -> SystemModule prism-to-box: - SystemModule(s) -> s + SystemModule(idf) -> idf // "(" SystemParallels ")" -> SystemBrackets prism-to-box: Index: src/lib/prism/pp/prism-command.str --- src/lib/prism/pp/prism-command.str (revision 21) +++ src/lib/prism/pp/prism-command.str (working copy) @@ -4,8 +4,8 @@ // "[" Identifier? "]" Expression "->" Updates ";" -> Command prism-to-box: - Command(Some(s), exp, updates) - -> H hs=0 [ "[" s H hs=1 [ "]" ~exp "->" ~updates ] ";" ] + Command(Some(idf), exp, updates) + -> H hs=0 [ "[" ~idf H hs=1 [ "]" ~exp "->" ~updates ] ";" ] prism-to-box: Command(None(), exp, updates) Index: src/syn/prism/PRISM-Literals.sdf --- src/syn/prism/PRISM-Literals.sdf (revision 21) +++ src/syn/prism/PRISM-Literals.sdf (working copy) @@ -9,10 +9,15 @@ %% NOTE: PRISM's grammar doesn't allow things such as "01" - sorts Int Double + sorts LInt LDouble lexical syntax - [1-9][0-9]* -> Int - "0" -> Int + [1-9][0-9]* -> LInt + "0" -> LInt + + [1-9][0-9]* "." [0-9]+ -> LDouble + "0" "." [0-9]+ -> LDouble - [1-9][0-9]* "." [0-9]+ -> Double - "0" "." [0-9]+ -> Double + sorts Int Double + context-free syntax + LInt -> Int {cons("Int")} + LDouble -> Double {cons("Double")} Index: src/syn/prism/PRISM-Identifier.sdf --- src/syn/prism/PRISM-Identifier.sdf (revision 21) +++ src/syn/prism/PRISM-Identifier.sdf (working copy) @@ -23,7 +23,7 @@ sorts Identifier IdentifierPrime ID context-free syntax - ID -> Identifier + ID -> Identifier {cons("Identifier")} ID "'" -> IdentifierPrime {cons("IdentifierPrime")} lexical syntax Index: src/syn/prism/PRISM-Expression.sdf --- src/syn/prism/PRISM-Expression.sdf (revision 21) +++ src/syn/prism/PRISM-Expression.sdf (working copy) @@ -116,11 +116,11 @@ %% Literals "true" -> Expression {cons("True")} "false" -> Expression {cons("False")} - Int -> Expression {cons("Int")} - Double -> Expression {cons("Double")} + Int -> Expression + Double -> Expression %% Variables - Identifier -> Expression {cons("Identifier")} + Identifier -> Expression %% Arithmetic and logical operations %% The order of the list defines the operator precedence Index: vcs/xrm.rb --- vcs/xrm.rb (revision 21) +++ vcs/xrm.rb (working copy) @@ -7,7 +7,7 @@ def xrm_commit! ( *args ) common_commit!("XRM 22: <%= title %>", *args) do |subject| - mail!(:to => %w[lrde-patches@lrde.epita.fr], :subject => subject) + mail!(:to => %w[projects@lrde.epita.fr], :subject => subject) end end alias_command :xrmci, :xrm_commit
participants (1)
-
SIGOURE Benoit