From 43c99f1d89f5c7551a9a33085cb22a145f30ace5 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 25 Nov 2018 23:42:37 +0100 Subject: [PATCH] strings of len 1 are no longer converted to byte value, plus some other tweaks --- compiler/examples/test.p8 | 98 +++-------- compiler/src/build_the_compiler.cmd | 2 +- compiler/src/build_the_compiler.sh | 2 +- .../src/prog8/optimizing/ConstantFolding.kt | 9 - compiler/src/prog8/parser/prog8Lexer.java | 133 +++++++------- compiler/src/prog8/parser/prog8Parser.java | 162 +++++++++--------- prog8lib/c64lib.p8 | 6 +- prog8lib/c64utils.p8 | 2 +- 8 files changed, 178 insertions(+), 236 deletions(-) diff --git a/compiler/examples/test.p8 b/compiler/examples/test.p8 index 832b13aa2..4a0dc1d81 100644 --- a/compiler/examples/test.p8 +++ b/compiler/examples/test.p8 @@ -7,88 +7,40 @@ sub start() { - ubyte v1 - ubyte v2 - float f2 - uword address - memory uword memaddr = $c000 - uword[2] wordarray - ubyte[2] ubytearray byte b1 - memory byte mb1 = $c991 - memory ubyte mub1 = $c992 + ubyte ub1 + memory byte mb1 = $c000 + memory ubyte mub1 = $c001 + ubyte[10] ubytearray + byte[10] bytearray + memory ubyte[10] memubytearray = $c100 + memory byte[10] membytearray=$c200 + word[10] wordarray - - str stringvar = "??????????\n\n\nnext line\r\r\rnext line after carriagereturn" - ubyte secretnumber = 0 - memory uword freadstr_arg = $22 ; argument for FREADSTR - uword testword - ubyte char1 = "@" ; @todo don't put this on the heap - ubyte char2 = "\n"; @todo don't put this on the heap - ubyte char3 = "\r"; @todo don't put this on the heap - ubyte char1b = '@' - ubyte char2b = '\n' - ubyte char3b = '\r' - - testword = '@' - testword = '\n' - freadstr_arg = '@' - freadstr_arg = '\n' - secretnumber = '@' - secretnumber = '\r' - - testword = stringvar - testword = wordarray - freadstr_arg = stringvar - freadstr_arg = wordarray - wordarray[1] = stringvar - wordarray[1] = wordarray - wordarray[b1] = stringvar - wordarray[b1] = wordarray - wordarray[mb1] = stringvar - wordarray[mb1] = wordarray - testword = "stringstring" ; @todo asmgen for this - freadstr_arg = "stringstring" ; @todo asmgen for this - freadstr_arg = "stringstring2222" ; @todo asmgen for this - wordarray[1] = "stringstring" ; @todo asmgen for this - wordarray[b1] = "stringstring" ; @todo asmgen for this - wordarray[mb1] = "stringstring" ; @todo asmgen for this - - - -; address =c64.MEMBOT(1, 40000.w) ; ok! -; address =c64.MEMBOT(1, address) ; ok! -; address =c64.MEMBOT(1, memaddr) ; ok! -; -; A, Y =c64.GETADR() ; ok! -; Y, A =c64.GETADR() ; ok! -; address = c64flt.GETADRAY() ; ok! -; memaddr = c64flt.GETADRAY() ; ok! -; wordarray[1] = c64flt.GETADRAY() ; ok! -; v1, v2 =c64.GETADR() ; ok! -; address =c64.IOBASE() ; ok! -; A = c64.CHRIN() ; ok ! -; X = c64.CHRIN() ; ok ! -; Y = c64.CHRIN() ; ok! -; v1 = c64.CHRIN() ; ok ! - - - c64.CHROUT(X) - c64.CHROUT(b1) ; @todo fix compiler crash expression identifierref should be a vardef, not null - c64.CHROUT(char1) ; @todo fix compiler crash " - c64.CHROUT(mb1) ; @todo fix compiler crash " - c64.CHROUT(mub1) ; @todo fix compiler crash " - c64.CHROUT(ubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl - c64.CHROUT(ubytearray[X]) ; @todo fix compiler crash " - c64.CHROUT(wordarray[1]) ; @todo fix compiler crash " + c64.CHROUT(X) + c64.CHROUT(b1) ; @todo fix compiler crash expression identifierref should be a vardef, not null + c64.CHROUT(ub1) ; @todo fix compiler crash expression identifierref should be a vardef, not null + c64.CHROUT(mb1) ; @todo fix compiler crash " + c64.CHROUT(mub1) ; @todo fix compiler crash " + c64.CHROUT(bytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl + c64.CHROUT(ubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl + c64.CHROUT(membytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl + c64.CHROUT(memubytearray[1]) ; @todo fix compiler crash null cannot be cast to non-null type prog8.ast.VarDecl + c64.CHROUT(ubytearray[X]) ; @todo fix compiler crash " + c64.CHROUT(memubytearray[X]) ; @todo fix compiler crash " + c64.CHROUT(wordarray[1]) ; @todo fix compiler crash " testsub(X) ; @todo fix compiler crash testsub(b1) ; @todo fix compiler crash - testsub(char1) ; @todo fix compiler crash + testsub(ub1) ; @todo fix compiler crash testsub(mb1) ; @todo fix compiler crash testsub(mub1) ; @todo fix compiler crash + testsub(bytearray[1]) ; @todo fix compiler crash testsub(ubytearray[1]) ; @todo fix compiler crash + testsub(membytearray[1]) ; @todo fix compiler crash + testsub(memubytearray[1]) ; @todo fix compiler crash testsub(ubytearray[X]) ; @todo fix compiler crash + testsub(memubytearray[X]) ; @todo fix compiler crash testsub(wordarray[1]) ; @todo fix compiler crash return diff --git a/compiler/src/build_the_compiler.cmd b/compiler/src/build_the_compiler.cmd index c427774af..60931769e 100644 --- a/compiler/src/build_the_compiler.cmd +++ b/compiler/src/build_the_compiler.cmd @@ -7,6 +7,6 @@ javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar @sourc @del sources.txt jar cf parser.jar -C compiled_java prog8 -set KOTLINC=%USERPROFILE%\.IdeaIC2018.2\config\plugins\kotlin\kotlinc\bin\kotlinc.bat +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 diff --git a/compiler/src/build_the_compiler.sh b/compiler/src/build_the_compiler.sh index 824bcd9f3..0f9476ec6 100755 --- a/compiler/src/build_the_compiler.sh +++ b/compiler/src/build_the_compiler.sh @@ -7,7 +7,7 @@ mkdir -p compiled_java javac -verbose -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar @javasources.txt rm javasources.txt -KOTLINC="bash ${HOME}/.IntelliJIdea2018.2/config/plugins/Kotlin/kotlinc/bin/kotlinc" +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 jar uf prog8_kotlin.jar -C compiled_java prog8 diff --git a/compiler/src/prog8/optimizing/ConstantFolding.kt b/compiler/src/prog8/optimizing/ConstantFolding.kt index 3546c5548..376c0f3f5 100644 --- a/compiler/src/prog8/optimizing/ConstantFolding.kt +++ b/compiler/src/prog8/optimizing/ConstantFolding.kt @@ -42,15 +42,6 @@ class ConstantFolding(private val namespace: INameScope, private val heap: HeapV decl.value = newValue } } - in IntegerDatatypes -> { - // vardecl: for byte/word vars, convert char/string of length 1 initialization values to ubyte integer - val literal = decl.value as? LiteralValue - if (literal != null && literal.isString && literal.strvalue(heap).length == 1) { - val petscii = Petscii.encodePetscii(literal.strvalue(heap), true)[0] - val newValue = LiteralValue(DataType.UBYTE, bytevalue = petscii, position = literal.position) - decl.value = newValue - } - } DataType.ARRAY_UB, DataType.ARRAY_B, DataType.ARRAY_UW, DataType.ARRAY_W -> { val litval = decl.value as? LiteralValue if(litval?.type==DataType.FLOAT) diff --git a/compiler/src/prog8/parser/prog8Lexer.java b/compiler/src/prog8/parser/prog8Lexer.java index c286843a5..909c74dc9 100644 --- a/compiler/src/prog8/parser/prog8Lexer.java +++ b/compiler/src/prog8/parser/prog8Lexer.java @@ -1,38 +1,39 @@ -// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7 +// Generated from ../antlr/prog8.g4 by ANTLR 4.7.1 package prog8.parser; - +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.LexerATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; +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.1", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, - T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, - T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, - T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, T__57=58, T__58=59, - T__59=60, T__60=61, T__61=62, T__62=63, T__63=64, T__64=65, T__65=66, - T__66=67, T__67=68, T__68=69, T__69=70, T__70=71, T__71=72, T__72=73, - T__73=74, T__74=75, T__75=76, T__76=77, T__77=78, T__78=79, T__79=80, - T__80=81, T__81=82, T__82=83, T__83=84, T__84=85, T__85=86, T__86=87, - T__87=88, T__88=89, T__89=90, T__90=91, T__91=92, T__92=93, T__93=94, - T__94=95, T__95=96, T__96=97, T__97=98, T__98=99, T__99=100, T__100=101, - T__101=102, T__102=103, T__103=104, T__104=105, T__105=106, T__106=107, - LINECOMMENT=108, COMMENT=109, WS=110, EOL=111, NAME=112, DEC_INTEGER=113, - HEX_INTEGER=114, BIN_INTEGER=115, FLOAT_NUMBER=116, STRING=117, INLINEASMBLOCK=118, + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, + T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, + T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, + T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, + T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, + T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, T__57=58, T__58=59, + T__59=60, T__60=61, T__61=62, T__62=63, T__63=64, T__64=65, T__65=66, + T__66=67, T__67=68, T__68=69, T__69=70, T__70=71, T__71=72, T__72=73, + T__73=74, T__74=75, T__75=76, T__76=77, T__77=78, T__78=79, T__79=80, + T__80=81, T__81=82, T__82=83, T__83=84, T__84=85, T__85=86, T__86=87, + T__87=88, T__88=89, T__89=90, T__90=91, T__91=92, T__92=93, T__93=94, + T__94=95, T__95=96, T__96=97, T__97=98, T__98=99, T__99=100, T__100=101, + T__101=102, T__102=103, T__103=104, T__104=105, T__105=106, T__106=107, + LINECOMMENT=108, COMMENT=109, WS=110, EOL=111, NAME=112, DEC_INTEGER=113, + HEX_INTEGER=114, BIN_INTEGER=115, FLOAT_NUMBER=116, STRING=117, INLINEASMBLOCK=118, SINGLECHAR=119; public static String[] channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN" @@ -43,51 +44,51 @@ public class prog8Lexer extends Lexer { }; 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", "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", - "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", "FNUMBER", "STRING_ESCAPE_SEQ", + "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", "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", + "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", "FNUMBER", "STRING_ESCAPE_SEQ", "STRING", "INLINEASMBLOCK", "SINGLECHAR" }; 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'", - "'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'", + 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'", + "'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, - "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", "HEX_INTEGER", + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + 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" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -168,7 +169,7 @@ public class prog8Lexer extends Lexer { // get rid of the enclosing quotes String s = getText(); setText(s.substring(1, s.length() - 1)); - + break; } } @@ -179,7 +180,7 @@ public class prog8Lexer extends Lexer { // get rid of the enclosing double braces String s = getText(); setText(s.substring(2, s.length() - 2)); - + break; } } @@ -190,7 +191,7 @@ public class prog8Lexer extends Lexer { // get rid of the enclosing quotes String s = getText(); setText(s.substring(1, s.length() - 1)); - + break; } } @@ -485,4 +486,4 @@ public class prog8Lexer extends Lexer { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } -} +} \ No newline at end of file diff --git a/compiler/src/prog8/parser/prog8Parser.java b/compiler/src/prog8/parser/prog8Parser.java index 42a869d40..429574fb6 100644 --- a/compiler/src/prog8/parser/prog8Parser.java +++ b/compiler/src/prog8/parser/prog8Parser.java @@ -1,103 +1,101 @@ -// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7 +// Generated from ../antlr/prog8.g4 by ANTLR 4.7.1 package prog8.parser; - -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.ParserATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.tree.TerminalNode; - +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; import java.util.List; +import java.util.Iterator; +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.1", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, - T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, - T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, - T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, T__57=58, T__58=59, - T__59=60, T__60=61, T__61=62, T__62=63, T__63=64, T__64=65, T__65=66, - T__66=67, T__67=68, T__68=69, T__69=70, T__70=71, T__71=72, T__72=73, - T__73=74, T__74=75, T__75=76, T__76=77, T__77=78, T__78=79, T__79=80, - T__80=81, T__81=82, T__82=83, T__83=84, T__84=85, T__85=86, T__86=87, - T__87=88, T__88=89, T__89=90, T__90=91, T__91=92, T__92=93, T__93=94, - T__94=95, T__95=96, T__96=97, T__97=98, T__98=99, T__99=100, T__100=101, - T__101=102, T__102=103, T__103=104, T__104=105, T__105=106, T__106=107, - LINECOMMENT=108, COMMENT=109, WS=110, EOL=111, NAME=112, DEC_INTEGER=113, - HEX_INTEGER=114, BIN_INTEGER=115, FLOAT_NUMBER=116, STRING=117, INLINEASMBLOCK=118, + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, + T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, + T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, + T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, + T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, + T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, T__57=58, T__58=59, + T__59=60, T__60=61, T__61=62, T__62=63, T__63=64, T__64=65, T__65=66, + T__66=67, T__67=68, T__68=69, T__69=70, T__70=71, T__71=72, T__72=73, + T__73=74, T__74=75, T__75=76, T__76=77, T__77=78, T__78=79, T__79=80, + T__80=81, T__81=82, T__82=83, T__83=84, T__84=85, T__85=86, T__86=87, + T__87=88, T__88=89, T__89=90, T__90=91, T__91=92, T__92=93, T__93=94, + T__94=95, T__95=96, T__96=97, T__97=98, T__98=99, T__99=100, T__100=101, + T__101=102, T__102=103, T__103=104, T__104=105, T__105=106, T__106=107, + LINECOMMENT=108, COMMENT=109, WS=110, EOL=111, NAME=112, DEC_INTEGER=113, + HEX_INTEGER=114, BIN_INTEGER=115, FLOAT_NUMBER=116, STRING=117, INLINEASMBLOCK=118, SINGLECHAR=119; public static final int - RULE_module = 0, RULE_modulestatement = 1, RULE_block = 2, RULE_statement = 3, - RULE_labeldef = 4, RULE_unconditionaljump = 5, RULE_directive = 6, RULE_directivearg = 7, - RULE_vardecl = 8, RULE_varinitializer = 9, RULE_constdecl = 10, RULE_memoryvardecl = 11, - RULE_datatype = 12, RULE_arrayspec = 13, RULE_assignment = 14, RULE_assign_targets = 15, - RULE_augassignment = 16, RULE_assign_target = 17, RULE_postincrdecr = 18, - RULE_expression = 19, RULE_arrayindexed = 20, RULE_functioncall = 21, - RULE_functioncall_stmt = 22, RULE_expression_list = 23, RULE_returnstmt = 24, - RULE_breakstmt = 25, RULE_continuestmt = 26, RULE_identifier = 27, RULE_scoped_identifier = 28, - RULE_register = 29, RULE_registerorpair = 30, RULE_statusregister = 31, - RULE_integerliteral = 32, RULE_wordsuffix = 33, RULE_booleanliteral = 34, - RULE_arrayliteral = 35, RULE_stringliteral = 36, RULE_charliteral = 37, - RULE_floatliteral = 38, RULE_literalvalue = 39, RULE_inlineasm = 40, RULE_subroutine = 41, - RULE_sub_return_part = 42, RULE_statement_block = 43, RULE_sub_params = 44, - RULE_sub_param = 45, RULE_sub_returns = 46, RULE_asmsubroutine = 47, RULE_asmsub_address = 48, - 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_module = 0, RULE_modulestatement = 1, RULE_block = 2, RULE_statement = 3, + RULE_labeldef = 4, RULE_unconditionaljump = 5, RULE_directive = 6, RULE_directivearg = 7, + RULE_vardecl = 8, RULE_varinitializer = 9, RULE_constdecl = 10, RULE_memoryvardecl = 11, + RULE_datatype = 12, RULE_arrayspec = 13, RULE_assignment = 14, RULE_assign_targets = 15, + RULE_augassignment = 16, RULE_assign_target = 17, RULE_postincrdecr = 18, + RULE_expression = 19, RULE_arrayindexed = 20, RULE_functioncall = 21, + RULE_functioncall_stmt = 22, RULE_expression_list = 23, RULE_returnstmt = 24, + RULE_breakstmt = 25, RULE_continuestmt = 26, RULE_identifier = 27, RULE_scoped_identifier = 28, + RULE_register = 29, RULE_registerorpair = 30, RULE_statusregister = 31, + RULE_integerliteral = 32, RULE_wordsuffix = 33, RULE_booleanliteral = 34, + RULE_arrayliteral = 35, RULE_stringliteral = 36, RULE_charliteral = 37, + RULE_floatliteral = 38, RULE_literalvalue = 39, RULE_inlineasm = 40, RULE_subroutine = 41, + RULE_sub_return_part = 42, RULE_statement_block = 43, RULE_sub_params = 44, + RULE_sub_param = 45, RULE_sub_returns = 46, RULE_asmsubroutine = 47, RULE_asmsub_address = 48, + 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", "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_param", "sub_returns", "asmsubroutine", "asmsub_address", "asmsub_params", - "asmsub_param", "clobber", "asmsub_returns", "asmsub_return", "if_stmt", - "else_part", "branch_stmt", "branchcondition", "forloop", "whileloop", + "module", "modulestatement", "block", "statement", "labeldef", "unconditionaljump", + "directive", "directivearg", "vardecl", "varinitializer", "constdecl", + "memoryvardecl", "datatype", "arrayspec", "assignment", "assign_targets", + "augassignment", "assign_target", "postincrdecr", "expression", "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_param", "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 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'", - "'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'", + 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'", + "'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, - "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", "HEX_INTEGER", + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + 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" }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); @@ -1677,7 +1675,7 @@ public class prog8Parser extends Parser { } break; } - } + } } setState(307); _errHandler.sync(this); @@ -2092,7 +2090,7 @@ public class prog8Parser extends Parser { { setState(355); match(NAME); - setState(358); + setState(358); _errHandler.sync(this); _alt = 1; do { @@ -2110,7 +2108,7 @@ public class prog8Parser extends Parser { default: throw new NoViableAltException(this); } - setState(360); + setState(360); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,26,_ctx); } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); @@ -4556,4 +4554,4 @@ public class prog8Parser extends Parser { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } -} +} \ No newline at end of file diff --git a/prog8lib/c64lib.p8 b/prog8lib/c64lib.p8 index 809b98591..2c3e8636c 100644 --- a/prog8lib/c64lib.p8 +++ b/prog8lib/c64lib.p8 @@ -26,9 +26,9 @@ memory uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in memory uword IRQ_VEC = $FFFE ; 6502 interrupt vector, determined by the kernal if banked in - const uword Screen = $0400 ; default character screen matrix - const uword Colors = $d800 ; character screen colors - + const uword Screen = $0400 ; default character screen matrix @todo matrix/array? needs to support array size > 255 + const uword Colors = $d800 ; character screen colors @todo matrix/array? needs to support array size > 255 + ; ---- VIC-II registers ---- diff --git a/prog8lib/c64utils.p8 b/prog8lib/c64utils.p8 index 1a8b4d1cb..ae410c88d 100644 --- a/prog8lib/c64utils.p8 +++ b/prog8lib/c64utils.p8 @@ -611,7 +611,7 @@ asmsub print_string (text: str @ XY) -> clobbers(A,Y) -> () { ; ---- print null terminated string from X/Y ; note: the compiler contains an optimization that will replace ; a call to this subroutine with a string argument of just one char, - ; by just one call to c64.CHROUT of that single char. + ; by just one call to c64.CHROUT of that single char. @todo do this %asm {{ stx c64.SCRATCH_ZP1 sty c64.SCRATCH_ZP2