Skip to content

Commit

Permalink
Some fixes to make OMCC leaner
Browse files Browse the repository at this point in the history
- Use inheritance for constants instead of passing them through each
  function.
- Use Modelica arrays (Integer yy_accept[:]) instead of MM arrays since
  Modelica arrays can be used as package constants.
- Move tokens, lexer tables, lexer code and lexer into the same file,
  inheriting from OMCCBaseLexer.mo.
  • Loading branch information
sjoelund committed Jun 27, 2015
1 parent 28812c9 commit 82d7955
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 439 deletions.
2 changes: 1 addition & 1 deletion openmodelica/bootstrapping/LoadCompilerSources.mos
Expand Up @@ -2,7 +2,7 @@

// "FrontEnd";
if true then /* Suppress output */
prefixPath := getEnvironmentVar("OMCOMPILERSOURCES")+"/";
prefixPath := if getEnvironmentVar("OMCOMPILERSOURCES")=="" then "../../../OMCompiler/Compiler/" else (getEnvironmentVar("OMCOMPILERSOURCES")+"/");
setCommandLineOptions("+g=MetaModelica");
files := {
prefixPath + "FrontEnd/Absyn.mo",
Expand Down
1 change: 1 addition & 0 deletions openmodelica/omcc/GenerateParser.mos
Expand Up @@ -16,6 +16,7 @@ loadFile(compilerSources + "Util/List.mo");
loadFile(compilerSources + "Util/Settings.mo");
loadFile(compilerSources + "Util/Corba.mo");
loadFile(compilerSources + "Util/Util.mo");
loadFile(compilerSources + "Util/StringUtil.mo");
loadFile(compilerSources + "Util/System.mo");
loadFile("TokenModelica.mo");
loadFile("LexTableModelica.mo");
Expand Down
27 changes: 9 additions & 18 deletions openmodelica/omcc/LexerCode.tmo
Expand Up @@ -6,31 +6,23 @@ encapsulated package %LexerCode% // Generated %time%
%time
%Token
%Lexer
%ParseTable
%LexTable
%constant
%nameSpan
%functions
%caseAction
*/
import Types;
import %Token%;
import %Lexer%;
import %ParseTable%;
import OMCCBaseLexer;
import OMCCTypes;
import Error;
%prologue%

function action
input Integer act;
input Integer startSt;
input Integer mm_currSt,mm_pos,mm_sPos,mm_ePos,mm_linenr,lineNrStart;
input Integer buffer;
input Boolean debug;
input String fileNm;
input String fileContents;
output OMCCTypes.Token token;
output Integer mm_startSt;
output Integer bufferRet;
extends OMCCBaseLexer;
redeclare package LexTable
%LexTable%
end LexTable;
%prologue%
redeclare function extends action
protected
OMCCTypes.Info info;
String sToken;
Expand All @@ -53,6 +45,5 @@ algorithm
end match;
end action;

%epilogue%

%Tokens%%epilogue%
end %LexerCode%;

0 comments on commit 82d7955

Please sign in to comment.