diff --git a/compiler/antlr/lib/antlr-4.7.1-complete.jar b/compiler/antlr/lib/antlr-4.7.1-complete.jar deleted file mode 100644 index ad02f7a46..000000000 Binary files a/compiler/antlr/lib/antlr-4.7.1-complete.jar and /dev/null differ diff --git a/compiler/antlr/lib/antlr-4.7.2-complete.jar b/compiler/antlr/lib/antlr-4.7.2-complete.jar new file mode 100644 index 000000000..9794f19b2 Binary files /dev/null and b/compiler/antlr/lib/antlr-4.7.2-complete.jar differ diff --git a/compiler/antlr/lib/antlr-runtime-4.7.1.jar b/compiler/antlr/lib/antlr-runtime-4.7.1.jar deleted file mode 100644 index e2e0ac72e..000000000 Binary files a/compiler/antlr/lib/antlr-runtime-4.7.1.jar and /dev/null differ diff --git a/compiler/antlr/lib/antlr-runtime-4.7.2.jar b/compiler/antlr/lib/antlr-runtime-4.7.2.jar new file mode 100644 index 000000000..7a27e1b20 Binary files /dev/null and b/compiler/antlr/lib/antlr-runtime-4.7.2.jar differ diff --git a/compiler/compiler.iml b/compiler/compiler.iml index 35568f7d3..6ab2902e4 100644 --- a/compiler/compiler.iml +++ b/compiler/compiler.iml @@ -10,7 +10,8 @@ - + + \ No newline at end of file diff --git a/compiler/src/build_the_compiler.cmd b/compiler/src/build_the_compiler.cmd index 60931769e..e4b12bb6a 100644 --- a/compiler/src/build_the_compiler.cmd +++ b/compiler/src/build_the_compiler.cmd @@ -1,12 +1,12 @@ mkdir compiled_java -java -jar ../antlr/lib/antlr-4.7.1-complete.jar -o ./prog8/parser -Xexact-output-dir -no-listener -no-visitor -package prog8.parser ../antlr/prog8.g4 +java -jar ../antlr/lib/antlr-4.7.2-complete.jar -o ./prog8/parser -Xexact-output-dir -no-listener -no-visitor -package prog8.parser ../antlr/prog8.g4 @dir /b /S src *.java > sources.txt -javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar @sources.txt +javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.2.jar @sources.txt @del sources.txt jar cf parser.jar -C compiled_java prog8 set KOTLINC=%USERPROFILE%\.IdeaIC2018.3\config\plugins\kotlin\kotlinc\bin\kotlinc.bat -%KOTLINC% -verbose -include-runtime -d prog8_kotlin.jar -cp ../antlr/lib/antlr-runtime-4.7.1.jar;parser.jar prog8 +%KOTLINC% -verbose -include-runtime -d prog8_kotlin.jar -cp ../antlr/lib/antlr-runtime-4.7.2.jar;parser.jar prog8 diff --git a/compiler/src/build_the_compiler.sh b/compiler/src/build_the_compiler.sh index 0f9476ec6..bcaffc60d 100755 --- a/compiler/src/build_the_compiler.sh +++ b/compiler/src/build_the_compiler.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash -java -jar ../antlr/lib/antlr-4.7.1-complete.jar -o ./prog8/parser -Xexact-output-dir -no-listener -no-visitor -package prog8.parser ../antlr/prog8.g4 +java -jar ../antlr/lib/antlr-4.7.2-complete.jar -o ./prog8/parser -Xexact-output-dir -no-listener -no-visitor -package prog8.parser ../antlr/prog8.g4 find prog8 -name \*.java > javasources.txt mkdir -p compiled_java -javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar @javasources.txt +javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.2.jar @javasources.txt rm javasources.txt KOTLINC="bash ${HOME}/.IntelliJIdea2018.3/config/plugins/Kotlin/kotlinc/bin/kotlinc" -${KOTLINC} -verbose -include-runtime -d prog8_kotlin.jar -cp ../antlr/lib/antlr-runtime-4.7.1.jar:compiled_java prog8 +${KOTLINC} -verbose -include-runtime -d prog8_kotlin.jar -cp ../antlr/lib/antlr-runtime-4.7.2.jar:compiled_java prog8 jar uf prog8_kotlin.jar -C compiled_java prog8 diff --git a/compiler/src/prog8/parser/prog8Lexer.java b/compiler/src/prog8/parser/prog8Lexer.java index 152cdd623..b198288ad 100644 --- a/compiler/src/prog8/parser/prog8Lexer.java +++ b/compiler/src/prog8/parser/prog8Lexer.java @@ -1,4 +1,4 @@ -// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7 +// Generated from ../antlr/prog8.g4 by ANTLR 4.7.2 package prog8.parser; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; @@ -11,7 +11,7 @@ import org.antlr.v4.runtime.misc.*; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class prog8Lexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } + static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = @@ -43,55 +43,65 @@ public class prog8Lexer extends Lexer { "DEFAULT_MODE" }; - public static final String[] ruleNames = { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", - "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", - "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", - "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", - "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", - "T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56", - "T__57", "T__58", "T__59", "T__60", "T__61", "T__62", "T__63", "T__64", - "T__65", "T__66", "T__67", "T__68", "T__69", "T__70", "T__71", "T__72", - "T__73", "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", "T__80", - "T__81", "T__82", "T__83", "T__84", "T__85", "T__86", "T__87", "T__88", - "T__89", "T__90", "T__91", "T__92", "T__93", "T__94", "T__95", "T__96", - "T__97", "T__98", "T__99", "T__100", "T__101", "T__102", "T__103", "T__104", - "T__105", "T__106", "T__107", "T__108", "LINECOMMENT", "COMMENT", "WS", - "EOL", "NAME", "DEC_INTEGER", "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", - "FNUMBER", "STRING_ESCAPE_SEQ", "STRING", "INLINEASMBLOCK", "SINGLECHAR" - }; + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", + "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", + "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", + "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", + "T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56", + "T__57", "T__58", "T__59", "T__60", "T__61", "T__62", "T__63", "T__64", + "T__65", "T__66", "T__67", "T__68", "T__69", "T__70", "T__71", "T__72", + "T__73", "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", "T__80", + "T__81", "T__82", "T__83", "T__84", "T__85", "T__86", "T__87", "T__88", + "T__89", "T__90", "T__91", "T__92", "T__93", "T__94", "T__95", "T__96", + "T__97", "T__98", "T__99", "T__100", "T__101", "T__102", "T__103", "T__104", + "T__105", "T__106", "T__107", "T__108", "LINECOMMENT", "COMMENT", "WS", + "EOL", "NAME", "DEC_INTEGER", "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", + "FNUMBER", "STRING_ESCAPE_SEQ", "STRING", "INLINEASMBLOCK", "SINGLECHAR" + }; + } + public static final String[] ruleNames = makeRuleNames(); - private static final String[] _LITERAL_NAMES = { - null, "'~'", "':'", "'goto'", "'%output'", "'%launcher'", "'%zeropage'", - "'%zpreserved'", "'%address'", "'%import'", "'%breakpoint'", "'%asminclude'", - "'%asmbinary'", "'%option'", "','", "'='", "'const'", "'memory'", "'ubyte'", - "'byte'", "'uword'", "'word'", "'float'", "'str'", "'str_p'", "'str_s'", - "'str_ps'", "'['", "']'", "'+='", "'-='", "'/='", "'//='", "'*='", "'**='", - "'&='", "'|='", "'^='", "'%='", "'++'", "'--'", "'('", "')'", "'+'", "'-'", - "'**'", "'*'", "'/'", "'//'", "'%'", "'<'", "'>'", "'<='", "'>='", "'=='", - "'!='", "'&'", "'^'", "'|'", "'to'", "'step'", "'and'", "'or'", "'xor'", - "'not'", "'as'", "'return'", "'break'", "'continue'", "'.'", "'A'", "'X'", - "'Y'", "'AX'", "'AY'", "'XY'", "'Pc'", "'Pz'", "'Pn'", "'Pv'", "'.w'", - "'true'", "'false'", "'%asm'", "'sub'", "'->'", "'{'", "'}'", "'asmsub'", - "'clobbers'", "'@'", "'if'", "'else'", "'if_cs'", "'if_cc'", "'if_eq'", - "'if_z'", "'if_ne'", "'if_nz'", "'if_pl'", "'if_pos'", "'if_mi'", "'if_neg'", - "'if_vs'", "'if_vc'", "'for'", "'in'", "'while'", "'repeat'", "'until'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", - "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", "STRING", "INLINEASMBLOCK", - "SINGLECHAR" - }; + private static String[] makeLiteralNames() { + return new String[] { + null, "'~'", "':'", "'goto'", "'%output'", "'%launcher'", "'%zeropage'", + "'%zpreserved'", "'%address'", "'%import'", "'%breakpoint'", "'%asminclude'", + "'%asmbinary'", "'%option'", "','", "'='", "'const'", "'memory'", "'ubyte'", + "'byte'", "'uword'", "'word'", "'float'", "'str'", "'str_p'", "'str_s'", + "'str_ps'", "'['", "']'", "'+='", "'-='", "'/='", "'//='", "'*='", "'**='", + "'&='", "'|='", "'^='", "'%='", "'++'", "'--'", "'('", "')'", "'+'", + "'-'", "'**'", "'*'", "'/'", "'//'", "'%'", "'<'", "'>'", "'<='", "'>='", + "'=='", "'!='", "'&'", "'^'", "'|'", "'to'", "'step'", "'and'", "'or'", + "'xor'", "'not'", "'as'", "'return'", "'break'", "'continue'", "'.'", + "'A'", "'X'", "'Y'", "'AX'", "'AY'", "'XY'", "'Pc'", "'Pz'", "'Pn'", + "'Pv'", "'.w'", "'true'", "'false'", "'%asm'", "'sub'", "'->'", "'{'", + "'}'", "'asmsub'", "'clobbers'", "'@'", "'if'", "'else'", "'if_cs'", + "'if_cc'", "'if_eq'", "'if_z'", "'if_ne'", "'if_nz'", "'if_pl'", "'if_pos'", + "'if_mi'", "'if_neg'", "'if_vs'", "'if_vc'", "'for'", "'in'", "'while'", + "'repeat'", "'until'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", + "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", "STRING", "INLINEASMBLOCK", + "SINGLECHAR" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** diff --git a/compiler/src/prog8/parser/prog8Parser.java b/compiler/src/prog8/parser/prog8Parser.java index 0982b9f89..3395cdef5 100644 --- a/compiler/src/prog8/parser/prog8Parser.java +++ b/compiler/src/prog8/parser/prog8Parser.java @@ -1,4 +1,4 @@ -// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7 +// Generated from ../antlr/prog8.g4 by ANTLR 4.7.2 package prog8.parser; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; @@ -11,7 +11,7 @@ import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class prog8Parser extends Parser { - static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } + static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = @@ -53,52 +53,62 @@ public class prog8Parser extends Parser { RULE_asmsub_params = 49, RULE_asmsub_param = 50, RULE_clobber = 51, RULE_asmsub_returns = 52, RULE_asmsub_return = 53, RULE_if_stmt = 54, RULE_else_part = 55, RULE_branch_stmt = 56, RULE_branchcondition = 57, RULE_forloop = 58, RULE_whileloop = 59, RULE_repeatloop = 60; - public static final String[] ruleNames = { - "module", "modulestatement", "block", "statement", "labeldef", "unconditionaljump", - "directive", "directivearg", "vardecl", "varinitializer", "constdecl", - "memoryvardecl", "datatype", "arrayspec", "assignment", "assign_targets", - "augassignment", "assign_target", "postincrdecr", "expression", "typecast", - "arrayindexed", "functioncall", "functioncall_stmt", "expression_list", - "returnstmt", "breakstmt", "continuestmt", "identifier", "scoped_identifier", - "register", "registerorpair", "statusregister", "integerliteral", "wordsuffix", - "booleanliteral", "arrayliteral", "stringliteral", "charliteral", "floatliteral", - "literalvalue", "inlineasm", "subroutine", "sub_return_part", "statement_block", - "sub_params", "sub_returns", "asmsubroutine", "asmsub_address", "asmsub_params", - "asmsub_param", "clobber", "asmsub_returns", "asmsub_return", "if_stmt", - "else_part", "branch_stmt", "branchcondition", "forloop", "whileloop", - "repeatloop" - }; + private static String[] makeRuleNames() { + return new String[] { + "module", "modulestatement", "block", "statement", "labeldef", "unconditionaljump", + "directive", "directivearg", "vardecl", "varinitializer", "constdecl", + "memoryvardecl", "datatype", "arrayspec", "assignment", "assign_targets", + "augassignment", "assign_target", "postincrdecr", "expression", "typecast", + "arrayindexed", "functioncall", "functioncall_stmt", "expression_list", + "returnstmt", "breakstmt", "continuestmt", "identifier", "scoped_identifier", + "register", "registerorpair", "statusregister", "integerliteral", "wordsuffix", + "booleanliteral", "arrayliteral", "stringliteral", "charliteral", "floatliteral", + "literalvalue", "inlineasm", "subroutine", "sub_return_part", "statement_block", + "sub_params", "sub_returns", "asmsubroutine", "asmsub_address", "asmsub_params", + "asmsub_param", "clobber", "asmsub_returns", "asmsub_return", "if_stmt", + "else_part", "branch_stmt", "branchcondition", "forloop", "whileloop", + "repeatloop" + }; + } + public static final String[] ruleNames = makeRuleNames(); - private static final String[] _LITERAL_NAMES = { - null, "'~'", "':'", "'goto'", "'%output'", "'%launcher'", "'%zeropage'", - "'%zpreserved'", "'%address'", "'%import'", "'%breakpoint'", "'%asminclude'", - "'%asmbinary'", "'%option'", "','", "'='", "'const'", "'memory'", "'ubyte'", - "'byte'", "'uword'", "'word'", "'float'", "'str'", "'str_p'", "'str_s'", - "'str_ps'", "'['", "']'", "'+='", "'-='", "'/='", "'//='", "'*='", "'**='", - "'&='", "'|='", "'^='", "'%='", "'++'", "'--'", "'('", "')'", "'+'", "'-'", - "'**'", "'*'", "'/'", "'//'", "'%'", "'<'", "'>'", "'<='", "'>='", "'=='", - "'!='", "'&'", "'^'", "'|'", "'to'", "'step'", "'and'", "'or'", "'xor'", - "'not'", "'as'", "'return'", "'break'", "'continue'", "'.'", "'A'", "'X'", - "'Y'", "'AX'", "'AY'", "'XY'", "'Pc'", "'Pz'", "'Pn'", "'Pv'", "'.w'", - "'true'", "'false'", "'%asm'", "'sub'", "'->'", "'{'", "'}'", "'asmsub'", - "'clobbers'", "'@'", "'if'", "'else'", "'if_cs'", "'if_cc'", "'if_eq'", - "'if_z'", "'if_ne'", "'if_nz'", "'if_pl'", "'if_pos'", "'if_mi'", "'if_neg'", - "'if_vs'", "'if_vc'", "'for'", "'in'", "'while'", "'repeat'", "'until'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", - "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", "STRING", "INLINEASMBLOCK", - "SINGLECHAR" - }; + private static String[] makeLiteralNames() { + return new String[] { + null, "'~'", "':'", "'goto'", "'%output'", "'%launcher'", "'%zeropage'", + "'%zpreserved'", "'%address'", "'%import'", "'%breakpoint'", "'%asminclude'", + "'%asmbinary'", "'%option'", "','", "'='", "'const'", "'memory'", "'ubyte'", + "'byte'", "'uword'", "'word'", "'float'", "'str'", "'str_p'", "'str_s'", + "'str_ps'", "'['", "']'", "'+='", "'-='", "'/='", "'//='", "'*='", "'**='", + "'&='", "'|='", "'^='", "'%='", "'++'", "'--'", "'('", "')'", "'+'", + "'-'", "'**'", "'*'", "'/'", "'//'", "'%'", "'<'", "'>'", "'<='", "'>='", + "'=='", "'!='", "'&'", "'^'", "'|'", "'to'", "'step'", "'and'", "'or'", + "'xor'", "'not'", "'as'", "'return'", "'break'", "'continue'", "'.'", + "'A'", "'X'", "'Y'", "'AX'", "'AY'", "'XY'", "'Pc'", "'Pz'", "'Pn'", + "'Pv'", "'.w'", "'true'", "'false'", "'%asm'", "'sub'", "'->'", "'{'", + "'}'", "'asmsub'", "'clobbers'", "'@'", "'if'", "'else'", "'if_cs'", + "'if_cc'", "'if_eq'", "'if_z'", "'if_ne'", "'if_nz'", "'if_pl'", "'if_pos'", + "'if_mi'", "'if_neg'", "'if_vs'", "'if_vc'", "'for'", "'in'", "'while'", + "'repeat'", "'until'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", + "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", "STRING", "INLINEASMBLOCK", + "SINGLECHAR" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** @@ -148,6 +158,7 @@ public class prog8Parser extends Parser { super(input); _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } + public static class ModuleContext extends ParserRuleContext { public TerminalNode EOF() { return getToken(prog8Parser.EOF, 0); } public List modulestatement() {