Skip to content

Commit

Permalink
+ Merging The new parallel extensions. The new keywords can be enable…
Browse files Browse the repository at this point in the history
…d by using +g=ParModelica.

  Actually enabling +g=MetaModelica also enables the ParModelica keywords, but not the other way around.
  I couldn't find a way to enable them completely separately. I will fix it if I can.
  But it will not cause problems since the new keywords are not common words.
  The testsuite didn't report any errors related to the new keywords. 
  But just make sure not to use them from now on while programming in MetaModelica.  
+ The keywords don't have any effect now. They are just consumed by the parser.   


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10591 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
mahge committed Nov 28, 2011
1 parent 193778e commit 590fbc3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Compiler/FrontEnd/Parser.mo
Expand Up @@ -48,7 +48,7 @@ public function parse "Parse a mo-file"
input String filename;
output Absyn.Program outProgram;
algorithm
outProgram := ParserExt.parse(filename, Config.acceptMetaModelicaGrammar(),
outProgram := ParserExt.parse(filename, Config.acceptedGrammar(),
Config.getRunningTestsuite());
end parse;

Expand All @@ -57,7 +57,7 @@ public function parseexp "Parse a mos-file"
output Interactive.Statements outStatements;
algorithm
outStatements := ParserExt.parseexp(filename,
Config.acceptMetaModelicaGrammar(), Config.getRunningTestsuite());
Config.acceptedGrammar(), Config.getRunningTestsuite());
end parseexp;

public function parsestring "Parse a string as if it were a stored definition"
Expand All @@ -66,7 +66,7 @@ public function parsestring "Parse a string as if it were a stored definition"
output Absyn.Program outProgram;
algorithm
outProgram := ParserExt.parsestring(str,infoFilename,
Config.acceptMetaModelicaGrammar(), Config.getRunningTestsuite());
Config.acceptedGrammar(), Config.getRunningTestsuite());
end parsestring;

public function parsestringexp "Parse a string as if it was a sequence of statements"
Expand All @@ -75,7 +75,7 @@ public function parsestringexp "Parse a string as if it was a sequence of statem
output Interactive.Statements outStatements;
algorithm
outStatements := ParserExt.parsestringexp(str,infoFilename,
Config.acceptMetaModelicaGrammar(), Config.getRunningTestsuite());
Config.acceptedGrammar(), Config.getRunningTestsuite());
end parsestringexp;
end Parser;

16 changes: 8 additions & 8 deletions Compiler/FrontEnd/ParserExt.mo
Expand Up @@ -44,38 +44,38 @@ public import Interactive;

public function parse "Parse a mo-file"
input String filename;
input Boolean acceptMM;
input Integer acceptedGram;
input Boolean runningTestsuite;
output Absyn.Program outProgram;

external "C" outProgram=ParserExt_parse(filename, acceptMM, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
external "C" outProgram=ParserExt_parse(filename, acceptedGram, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
end parse;

public function parseexp "Parse a mos-file"
input String filename;
input Boolean acceptMM;
input Integer acceptedGram;
input Boolean runningTestsuite;
output Interactive.Statements outStatements;

external "C" outStatements=ParserExt_parseexp(filename, acceptMM, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
external "C" outStatements=ParserExt_parseexp(filename, acceptedGram, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
end parseexp;

public function parsestring "Parse a string as if it were a stored definition"
input String str;
input String infoFilename := "<interactive>";
input Boolean acceptMM;
input Integer acceptedGram;
input Boolean runningTestsuite;
output Absyn.Program outProgram;
external "C" outProgram=ParserExt_parsestring(str,infoFilename, acceptMM, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
external "C" outProgram=ParserExt_parsestring(str,infoFilename, acceptedGram, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
end parsestring;

public function parsestringexp "Parse a string as if it was a sequence of statements"
input String str;
input String infoFilename := "<interactive>";
input Boolean acceptMM;
input Integer acceptedGram;
input Boolean runningTestsuite;
output Interactive.Statements outStatements;
external "C" outStatements=ParserExt_parsestringexp(str,infoFilename, acceptMM, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
external "C" outStatements=ParserExt_parsestringexp(str,infoFilename, acceptedGram, runningTestsuite) annotation(Library = {"omparse","antlr3","omcruntime"});
end parsestringexp;
end ParserExt;

21 changes: 20 additions & 1 deletion Compiler/Util/Config.mo
Expand Up @@ -138,15 +138,34 @@ algorithm
outBoolean := Flags.getConfigBool(Flags.HELP);
end helpRequest;

public function acceptedGrammar
"@author: mahge 2011-11-28
returns: the flag number representing the accepted grammer. Instead of using
booleans. This way more extensions can be added easily.
usage: omc [+g=Modelica|MetaModelica|ParModelica] = [1|2|3], default to 'Modelica'."
output Integer outGrammer;
algorithm
outGrammer := Flags.getConfigEnum(Flags.GRAMMAR);
end acceptedGrammar;

public function acceptMetaModelicaGrammar
"@author: adrpo 2007-06-11
returns: true if MetaModelica grammar is accepted or false otherwise
usage: omc [+g=Modelica|MetaModelica], default to 'Modelica'."
usage: omc [+g=Modelica|MetaModelica|ParModelica], default to 'Modelica'."
output Boolean outBoolean;
algorithm
outBoolean := intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.METAMODELICA);
end acceptMetaModelicaGrammar;

public function acceptParModelicaGrammar
"@author: mahge 2011-11-28
returns: true if ParModelica grammar is accepted or false otherwise
usage: omc [+g=Modelica|MetaModelica|ParModelica], default to 'Modelica'."
output Boolean outBoolean;
algorithm
outBoolean := intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.PARMODELICA);
end acceptParModelicaGrammar;

public function getAnnotationVersion
"@author: adrpo 2008-11-28
returns what flag was given at start
Expand Down
5 changes: 3 additions & 2 deletions Compiler/Util/Flags.mo
Expand Up @@ -157,6 +157,7 @@ end ValidOptions;
// Change this to a proper enum when we have support for them.
public constant Integer MODELICA = 1;
public constant Integer METAMODELICA = 2;
public constant Integer PARMODELICA = 3;

// DEBUG FLAGS
public
Expand Down Expand Up @@ -444,8 +445,8 @@ constant ConfigFlag TARGET = CONFIG_FLAG(5, "target", NONE(), EXTERNAL(),
STRING_FLAG("gcc"), SOME(STRING_OPTION({"gcc, msvc"})),
"Sets the target compiler to use.");
constant ConfigFlag GRAMMAR = CONFIG_FLAG(6, "grammar", SOME("g"), EXTERNAL(),
ENUM_FLAG(MODELICA, {("Modelica", MODELICA), ("MetaModelica", METAMODELICA)}),
SOME(STRING_OPTION({"Modelica", "MetaModelica"})),
ENUM_FLAG(MODELICA, {("Modelica", MODELICA), ("MetaModelica", METAMODELICA), ("ParModelica", PARMODELICA)}),
SOME(STRING_OPTION({"Modelica", "MetaModelica", "ParModelica"})),
"Sets the grammar and semantics to accept.");
constant ConfigFlag ANNOTATION_VERSION = CONFIG_FLAG(7, "annotationVersion",
NONE(), EXTERNAL(), STRING_FLAG("3.x"), SOME(STRING_OPTION({"1.x", "2.x", "3.x"})),
Expand Down

0 comments on commit 590fbc3

Please sign in to comment.