diff --git a/Parser/Makefile b/Parser/Makefile index bedd621e87b..5c01724da6c 100644 --- a/Parser/Makefile +++ b/Parser/Makefile @@ -3,7 +3,7 @@ all: libantlr3.a ModelicaLexer.c ModelicaParser.c ModelicaParser libantlr3.a: antlr-3.2/runtime/C/src/* antlr-3.2/runtime/C/include/* # build the library - gcc -O3 -c antlr-3.2/runtime/C/src/*.c -Iantlr-3.2/runtime/C/include + gcc -O3 -c antlr-3.2/runtime/C/src/*.c -Iantlr-3.2/runtime/C/include -Iantlr-3.2/runtime/C ar -ru libantlr3.a *.o ranlib libantlr3.a rm -f *.o @@ -12,7 +12,7 @@ ModelicaLexer.c ModelicaParser.c: Modelica.g ./runantlr.sh ModelicaParser: libantlr3.a ModelicaLexer.c ModelicaParser.c - gcc -O3 -o ModelicaParser *.c -I. -Iantlr-3.2/runtime/C/include -L. -lantlr3 + gcc -O3 -o ModelicaParser *.c -I. -Iantlr-3.2/runtime/C -Iantlr-3.2/runtime/C/include -L. -lantlr3 mkdir -p Release cp -f ModelicaParser Release/ModelicaParser @@ -23,4 +23,4 @@ clean: rm -f *.o *.a ModelicaParser.c ModelicaParser.h ModelicaLexer.c ModelicaLexer.h ModelicaParser \ ModelicaParser.exe ./Release/ModelicaParser.exe ./Release/ModelicaParser - \ No newline at end of file + diff --git a/Parser/Modelica.g b/Parser/Modelica.g index 7dc5210ac1a..2dd9babe776 100644 --- a/Parser/Modelica.g +++ b/Parser/Modelica.g @@ -1,32 +1,32 @@ /* - * This file is part of OpenModelica. - * - * Copyright (c) 1998-CurrentYear, Linköping University, - * Department of Computer and Information Science, - * SE-58183 Linköping, Sweden. - * - * All rights reserved. - * - * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 - * AND THIS OSMC PUBLIC LICENSE (OSMC-PL). - * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S - * ACCEPTANCE OF THE OSMC PUBLIC LICENSE. - * - * The OpenModelica software and the Open Source Modelica - * Consortium (OSMC) Public License (OSMC-PL) are obtained - * from Linköping University, either from the above address, - * from the URLs: http://www.ida.liu.se/projects/OpenModelica or - * http://www.openmodelica.org, and in the OpenModelica distribution. - * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. - * - * This program is distributed WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH - * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS - * OF OSMC-PL. - * - * See the full OSMC Public License conditions for more details. - * + * This file is part of OpenModelica. + * + * Copyright (c) 1998-CurrentYear, Linkoping University, + * Department of Computer and Information Science, + * SE-58183 Linkoping, Sweden. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 + * AND THIS OSMC PUBLIC LICENSE (OSMC-PL). + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S + * ACCEPTANCE OF THE OSMC PUBLIC LICENSE. + * + * The OpenModelica software and the Open Source Modelica + * Consortium (OSMC) Public License (OSMC-PL) are obtained + * from Linkoping University, either from the above address, + * from the URLs: http://www.ida.liu.se/projects/OpenModelica or + * http://www.openmodelica.org, and in the OpenModelica distribution. + * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS + * OF OSMC-PL. + * + * See the full OSMC Public License conditions for more details. + * */ grammar Modelica; diff --git a/Parser/Modelica.tokens b/Parser/Modelica.tokens index 4b21b8ed5ab..d1aa7c282d0 100644 --- a/Parser/Modelica.tokens +++ b/Parser/Modelica.tokens @@ -1,255 +1,255 @@ -FUNCTION=32 -PACKAGE=47 -UNQUALIFIED=138 -CLASS_EXTENDS=98 -EXTERNAL=27 -EXPONENT=163 -ALGORITHM_STATEMENT=95 -STAR=142 -WHILE=61 -FOR_INDICES=123 -QIDENT=159 -MOD=94 -CONNECTOR=11 -INITIAL_FUNCTION_CALL=126 -CASE=67 -CLASS_DEFINITION=97 -EQUATION=22 -EQUALS=84 -ELSEWHEN=19 -T_OR=45 -T_AND=5 -BREAK=64 -UNARY_PLUS=135 -TYPE=58 -CODE=8 -FINAL=29 -IMPORT=34 -GREATER=148 -LPAR=78 -CONNECT=10 -ENUMERATION=21 -LOOP=39 -PARAMETER=48 -LESS=145 -RETURN=63 -RANGE2=130 -QUALIFIED=129 -INITIAL_EQUATION=117 -ELEMENT=112 -REPLACEABLE=54 -RANGE3=131 -T_END=20 -EXPANDABLE=24 -ENCAPSULATED=23 -T_TRUE=57 -MATCHCONTINUE=72 -NL=153 -EACH=16 -UNARY_PLUS_EW=137 -COMMENT=107 -STREAM=65 -CODE_MODIFICATION=101 -EQEQ=150 -T_OUTER=42 -RBRACK=81 -EXTERNAL_FUNCTION_CALL=122 -T_INPUT=38 -RECORD=52 -RBRACE=83 -LINE_COMMENT=155 -INITIAL_ALGORITHM=118 -INITIAL=36 -ELSE=17 -POWER=151 -UNARY_MINUS=134 -MATCH=71 -SEMICOLON=88 -LOCAL=70 -RESULTS=55 -WILD=74 -T_IN=35 -EMPTY=141 -IDENT_LIST=120 -T_OUTPUT=46 -PLUS_EW=89 -COLONCOLON=76 -WS=154 -QCHAR=161 -FLOW=30 -T_FALSE=28 -NONDIGIT=157 -WITHIN=62 -CONSTANT=12 -UNARY_MINUS_EW=136 -POWER_EW=93 -FUNCTION_CALL=125 -CLASS_MODIFICATION=99 -NAMED_ARGUMENTS=128 -EQUALITY=68 -CODE_ALGORITHM=105 -PROTECTED=50 -CLASS=9 -LBRACK=80 -INNER=37 -DISCRETE=13 -STRING_GUTS=165 -LBRACE=82 -DER=14 -FOR=31 -UNSIGNED_REAL=59 -STORED_DEFINITION=132 -T_ANNOTATION=6 -TYPE_LIST=140 -DECLARATION=109 -IF=33 -ML_COMMENT=156 -AS=66 -UNSIGNED_INTEGER=164 -SLASH=152 -SCHAR=167 -THEN=56 -EXPRESSION_LIST=121 -LESSEQ=146 -COMMA=86 -FAILURE=69 -SUBTYPEOF=75 -EQUATION_STATEMENT=115 -SESCAPE=162 -DEFINITION=110 -FLAT_IDENT=139 -EXTERNAL_ANNOTATION=116 -ENUMERATION_LITERAL=111 -IDENT=160 -ARGUMENT_LIST=96 -PLUS=144 -MODEL=40 -DIGIT=158 -DOT=77 -MINUS_EW=90 -ELEMENT_REDECLARATION=114 -CONSTRAINEDBY=26 -PARTIAL=49 -GREATEREQ=149 -CODE_EXPRESSION=100 -DEFINEUNIT=15 -CODE_ELEMENT=102 -IMPORT_DEFINITION=119 -FUNCTION_ARGUMENTS=127 -OPERATOR=43 -T_ALGORITHM=4 -CODE_INITIALALGORITHM=106 -STAR_EW=91 -MINUS=143 -REDECLARE=53 -CODE_EQUATION=103 -ELEMENT_MODIFICATION=113 -ELSEIF=18 -LESSGT=147 -COLON=87 -CODE_INITIALEQUATION=104 -SLASH_EW=92 -UNIONTYPE=73 -WHEN=60 -BLOCK=7 -ASSIGN=85 -OVERLOAD=44 -RPAR=79 -STRING_COMMENT=133 -COMPONENT_DEFINITION=108 -T_NOT=41 -EXTENDS=25 -PUBLIC=51 -FOR_ITERATOR=124 -STRING=166 -'end'=20 -'results'=55 -'model'=40 -'then'=56 -':='=85 -'failure'=69 -'type'=58 -';'=88 -'enumeration'=21 -'defineunit'=15 -'return'=63 -'operator'=43 -'encapsulated'=23 -'for'=31 -'protected'=50 -'inner'=37 -'.'=77 -'stream'=65 -'constant'=12 -'function'=32 -'loop'=39 -'import'=34 -'elseif'=18 -'true'=57 -'unsigned_real'=59 -'.+'=89 -'matchcontinue'=72 -'else'=17 -'der'=14 -'final'=29 -'extends'=25 -'break'=64 -'and'=5 -'{'=82 -'as'=66 -'package'=47 -'match'=71 -'flow'=30 -'if'=33 -':'=87 -'('=78 -'subtypeof'=75 -'not'=41 -'while'=61 -'expandable'=24 -','=86 -'annotation'=6 -'in'=35 -'public'=51 -'each'=16 -'input'=38 -']'=81 -'class'=9 -'when'=60 -'outer'=42 -'equation'=22 -'.^'=93 -'constrainedby'=26 -'output'=46 -'redeclare'=53 -'overload'=44 -'.*'=91 -'within'=62 -'='=84 -'equality'=68 -'elsewhen'=19 -'::'=76 -'_'=74 -'parameter'=48 -')'=79 -'initial'=36 -'%'=94 -'./'=92 -'case'=67 -'connector'=11 -'.-'=90 -'}'=83 -'block'=7 -'$Code'=8 -'partial'=49 -'algorithm'=4 -'connect'=10 -'false'=28 -'external'=27 -'uniontype'=73 -'replaceable'=54 -'['=80 -'or'=45 -'local'=70 -'discrete'=13 -'record'=52 +FUNCTION=32 +PACKAGE=47 +UNQUALIFIED=138 +CLASS_EXTENDS=98 +EXTERNAL=27 +EXPONENT=163 +ALGORITHM_STATEMENT=95 +STAR=142 +WHILE=61 +FOR_INDICES=123 +QIDENT=159 +MOD=94 +CONNECTOR=11 +INITIAL_FUNCTION_CALL=126 +CASE=67 +CLASS_DEFINITION=97 +EQUATION=22 +EQUALS=84 +ELSEWHEN=19 +T_OR=45 +T_AND=5 +BREAK=64 +UNARY_PLUS=135 +TYPE=58 +CODE=8 +FINAL=29 +IMPORT=34 +GREATER=148 +LPAR=78 +CONNECT=10 +ENUMERATION=21 +LOOP=39 +PARAMETER=48 +LESS=145 +RETURN=63 +RANGE2=130 +QUALIFIED=129 +INITIAL_EQUATION=117 +ELEMENT=112 +REPLACEABLE=54 +RANGE3=131 +T_END=20 +EXPANDABLE=24 +ENCAPSULATED=23 +T_TRUE=57 +MATCHCONTINUE=72 +NL=153 +EACH=16 +UNARY_PLUS_EW=137 +COMMENT=107 +STREAM=65 +CODE_MODIFICATION=101 +EQEQ=150 +T_OUTER=42 +RBRACK=81 +EXTERNAL_FUNCTION_CALL=122 +T_INPUT=38 +RECORD=52 +RBRACE=83 +LINE_COMMENT=155 +INITIAL_ALGORITHM=118 +INITIAL=36 +ELSE=17 +POWER=151 +UNARY_MINUS=134 +MATCH=71 +SEMICOLON=88 +LOCAL=70 +RESULTS=55 +WILD=74 +T_IN=35 +EMPTY=141 +IDENT_LIST=120 +T_OUTPUT=46 +PLUS_EW=89 +COLONCOLON=76 +WS=154 +QCHAR=161 +FLOW=30 +T_FALSE=28 +NONDIGIT=157 +WITHIN=62 +CONSTANT=12 +UNARY_MINUS_EW=136 +POWER_EW=93 +FUNCTION_CALL=125 +CLASS_MODIFICATION=99 +NAMED_ARGUMENTS=128 +EQUALITY=68 +CODE_ALGORITHM=105 +PROTECTED=50 +CLASS=9 +LBRACK=80 +INNER=37 +DISCRETE=13 +STRING_GUTS=165 +LBRACE=82 +DER=14 +FOR=31 +UNSIGNED_REAL=59 +STORED_DEFINITION=132 +T_ANNOTATION=6 +TYPE_LIST=140 +DECLARATION=109 +IF=33 +ML_COMMENT=156 +AS=66 +UNSIGNED_INTEGER=164 +SLASH=152 +SCHAR=167 +THEN=56 +EXPRESSION_LIST=121 +LESSEQ=146 +COMMA=86 +FAILURE=69 +SUBTYPEOF=75 +EQUATION_STATEMENT=115 +SESCAPE=162 +DEFINITION=110 +FLAT_IDENT=139 +EXTERNAL_ANNOTATION=116 +ENUMERATION_LITERAL=111 +IDENT=160 +ARGUMENT_LIST=96 +PLUS=144 +MODEL=40 +DIGIT=158 +DOT=77 +MINUS_EW=90 +ELEMENT_REDECLARATION=114 +CONSTRAINEDBY=26 +PARTIAL=49 +GREATEREQ=149 +CODE_EXPRESSION=100 +DEFINEUNIT=15 +CODE_ELEMENT=102 +IMPORT_DEFINITION=119 +FUNCTION_ARGUMENTS=127 +OPERATOR=43 +T_ALGORITHM=4 +CODE_INITIALALGORITHM=106 +STAR_EW=91 +MINUS=143 +REDECLARE=53 +CODE_EQUATION=103 +ELEMENT_MODIFICATION=113 +ELSEIF=18 +LESSGT=147 +COLON=87 +CODE_INITIALEQUATION=104 +SLASH_EW=92 +UNIONTYPE=73 +WHEN=60 +BLOCK=7 +ASSIGN=85 +OVERLOAD=44 +RPAR=79 +STRING_COMMENT=133 +COMPONENT_DEFINITION=108 +T_NOT=41 +EXTENDS=25 +PUBLIC=51 +FOR_ITERATOR=124 +STRING=166 +'end'=20 +'results'=55 +'model'=40 +'then'=56 +':='=85 +'failure'=69 +'type'=58 +';'=88 +'enumeration'=21 +'defineunit'=15 +'return'=63 +'operator'=43 +'encapsulated'=23 +'for'=31 +'protected'=50 +'inner'=37 +'.'=77 +'stream'=65 +'constant'=12 +'function'=32 +'loop'=39 +'import'=34 +'elseif'=18 +'true'=57 +'unsigned_real'=59 +'.+'=89 +'matchcontinue'=72 +'else'=17 +'der'=14 +'final'=29 +'extends'=25 +'break'=64 +'and'=5 +'{'=82 +'as'=66 +'package'=47 +'match'=71 +'flow'=30 +'if'=33 +':'=87 +'('=78 +'subtypeof'=75 +'not'=41 +'while'=61 +'expandable'=24 +','=86 +'annotation'=6 +'in'=35 +'public'=51 +'each'=16 +'input'=38 +']'=81 +'class'=9 +'when'=60 +'outer'=42 +'equation'=22 +'.^'=93 +'constrainedby'=26 +'output'=46 +'redeclare'=53 +'overload'=44 +'.*'=91 +'within'=62 +'='=84 +'equality'=68 +'elsewhen'=19 +'::'=76 +'_'=74 +'parameter'=48 +')'=79 +'initial'=36 +'%'=94 +'./'=92 +'case'=67 +'connector'=11 +'.-'=90 +'}'=83 +'block'=7 +'$Code'=8 +'partial'=49 +'algorithm'=4 +'connect'=10 +'false'=28 +'external'=27 +'uniontype'=73 +'replaceable'=54 +'['=80 +'or'=45 +'local'=70 +'discrete'=13 +'record'=52 diff --git a/Parser/main.c b/Parser/main.c index 3a7dffd9573..72358b6ef53 100644 --- a/Parser/main.c +++ b/Parser/main.c @@ -12,9 +12,7 @@ long unsigned int szMemoryUsed = 0; #include #include -HANDLE semaphore; - -DWORD WINAPI parseFile(char* fileName) +int parseFile(char* fileName) { pANTLR3_UINT8 fName; pANTLR3_INPUT_STREAM input; @@ -53,6 +51,7 @@ DWORD WINAPI parseFile(char* fileName) return 0; } +#if defined(_MSC_VER) int hasMoFiles(char* directory) { WIN32_FIND_DATA FileData; @@ -146,6 +145,7 @@ int recurseDirectories(char* directory) } return 0; } +#endif int main(int argc,char* argv[]) { @@ -153,12 +153,14 @@ int main(int argc,char* argv[]) if ( argc < 3 ) fprintf(stderr, "Usage: %s [-f Model.mo|-d directory]\n",argv[0]),exit(1); +#if defined(_MSC_VER) if (strcmp(argv[1],"-d") == 0) { parseMoFilesInDirectory(argv[2]); recurseDirectories(argv[2]); fprintf(stderr, "No more .mo files!\n"); } +#endif if (strcmp(argv[1],"-f") == 0) { diff --git a/Parser/runantlr.sh b/Parser/runantlr.sh old mode 100644 new mode 100755