diff --git a/compile.sh b/compile.sh index 1561419c5..1628aafa2 100755 --- a/compile.sh +++ b/compile.sh @@ -1,9 +1,8 @@ #!/usr/bin/env sh -PROG8_COMPILER_DIR=compiler -PROG8_LIBDIR=${PROG8_COMPILER_DIR}/prog8lib -PROG8CLASSPATH=${PROG8_COMPILER_DIR}/out/production/compiler +PROG8_LIBDIR=./out/production/compiler/prog8lib +PROG8CLASSPATH=./out/production/compiler:./out/production/parser KOTLINPATH=${HOME}/.IntelliJIdea2018.3/config/plugins/Kotlin -LIBJARS=${KOTLINPATH}/lib/kotlin-stdlib.jar:${KOTLINPATH}/lib/kotlin-reflect.jar:${PROG8_COMPILER_DIR}/antlr/lib/antlr-runtime-4.7.2.jar +LIBJARS=${KOTLINPATH}/lib/kotlin-stdlib.jar:${KOTLINPATH}/lib/kotlin-reflect.jar:./parser//antlr/lib/antlr-runtime-4.7.2.jar java -Dprog8.libdir=${PROG8_LIBDIR} -cp ${PROG8CLASSPATH}:${LIBJARS} prog8.CompilerMainKt $* diff --git a/compiler/compiler.iml b/compiler/compiler.iml index 6ab2902e4..9edcde403 100644 --- a/compiler/compiler.iml +++ b/compiler/compiler.iml @@ -4,14 +4,14 @@ - + - + + - - + \ No newline at end of file diff --git a/compiler/prog8lib/c64flt.p8 b/compiler/res/prog8lib/c64flt.p8 similarity index 100% rename from compiler/prog8lib/c64flt.p8 rename to compiler/res/prog8lib/c64flt.p8 diff --git a/compiler/prog8lib/c64lib.p8 b/compiler/res/prog8lib/c64lib.p8 similarity index 100% rename from compiler/prog8lib/c64lib.p8 rename to compiler/res/prog8lib/c64lib.p8 diff --git a/compiler/prog8lib/c64utils.p8 b/compiler/res/prog8lib/c64utils.p8 similarity index 100% rename from compiler/prog8lib/c64utils.p8 rename to compiler/res/prog8lib/c64utils.p8 diff --git a/compiler/prog8lib/prog8lib.p8 b/compiler/res/prog8lib/prog8lib.p8 similarity index 100% rename from compiler/prog8lib/prog8lib.p8 rename to compiler/res/prog8lib/prog8lib.p8 diff --git a/compiler/src/prog8/parser/ModuleParsing.kt b/compiler/src/prog8/parser/ModuleParsing.kt index a1c0119cc..9da40d9a8 100644 --- a/compiler/src/prog8/parser/ModuleParsing.kt +++ b/compiler/src/prog8/parser/ModuleParsing.kt @@ -82,6 +82,9 @@ fun importModule(filePath: Path) : Module { fun discoverImportedModule(name: String, importedFrom: Path, position: Position?): Path { + + // @todo: be able to actually load the library p8's as a resource instead of from a file + val fileName = "$name.p8" val locations = mutableListOf(Paths.get(importedFrom.parent.toString())) diff --git a/docs/docs.iml b/docs/docs.iml index 28bcee67e..ad3c0a365 100644 --- a/docs/docs.iml +++ b/docs/docs.iml @@ -2,10 +2,8 @@ - - - - + + \ No newline at end of file diff --git a/examples/wizzine.p8 b/examples/wizzine.p8 index cb2807cd9..25566132e 100644 --- a/examples/wizzine.p8 +++ b/examples/wizzine.p8 @@ -37,7 +37,7 @@ c64.SPRPTR[i] = $0a00/64 } c64.SPENA = 255 ; enable all sprites - c64utils.set_rasterirq(200) ; enable animation + c64utils.set_rasterirq(270) ; enable animation } } diff --git a/compiler/antlr/Makefile b/parser/antlr/Makefile similarity index 100% rename from compiler/antlr/Makefile rename to parser/antlr/Makefile diff --git a/compiler/antlr/antlr.sh b/parser/antlr/antlr.sh similarity index 100% rename from compiler/antlr/antlr.sh rename to parser/antlr/antlr.sh diff --git a/compiler/antlr/grun.sh b/parser/antlr/grun.sh similarity index 100% rename from compiler/antlr/grun.sh rename to parser/antlr/grun.sh diff --git a/compiler/antlr/lib/antlr-4.7.2-complete.jar b/parser/antlr/lib/antlr-4.7.2-complete.jar similarity index 100% rename from compiler/antlr/lib/antlr-4.7.2-complete.jar rename to parser/antlr/lib/antlr-4.7.2-complete.jar diff --git a/compiler/antlr/lib/antlr-runtime-4.7.2.jar b/parser/antlr/lib/antlr-runtime-4.7.2.jar similarity index 100% rename from compiler/antlr/lib/antlr-runtime-4.7.2.jar rename to parser/antlr/lib/antlr-runtime-4.7.2.jar diff --git a/compiler/antlr/prog8.g4 b/parser/antlr/prog8.g4 similarity index 100% rename from compiler/antlr/prog8.g4 rename to parser/antlr/prog8.g4 diff --git a/parser/parser.iml b/parser/parser.iml new file mode 100644 index 000000000..5e50e4456 --- /dev/null +++ b/parser/parser.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/compiler/src/prog8/parser/prog8Lexer.java b/parser/src/prog8/parser/prog8Lexer.java similarity index 97% rename from compiler/src/prog8/parser/prog8Lexer.java rename to parser/src/prog8/parser/prog8Lexer.java index 7ddd722f7..a469758cf 100644 --- a/compiler/src/prog8/parser/prog8Lexer.java +++ b/parser/src/prog8/parser/prog8Lexer.java @@ -1,4 +1,4 @@ -// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7.2 +// Generated from /home/irmen/Projects/prog8/parser/antlr/prog8.g4 by ANTLR 4.7.2 package prog8.parser; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; @@ -17,23 +17,23 @@ public class prog8Lexer extends Lexer { 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, - T__107=108, T__108=109, T__109=110, T__110=111, T__111=112, LINECOMMENT=113, - COMMENT=114, WS=115, EOL=116, NAME=117, DEC_INTEGER=118, HEX_INTEGER=119, + 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, + T__107=108, T__108=109, T__109=110, T__110=111, T__111=112, LINECOMMENT=113, + COMMENT=114, WS=115, EOL=116, NAME=117, DEC_INTEGER=118, HEX_INTEGER=119, BIN_INTEGER=120, FLOAT_NUMBER=121, STRING=122, INLINEASMBLOCK=123, SINGLECHAR=124; public static String[] channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN" @@ -45,22 +45,22 @@ public class prog8Lexer extends Lexer { 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", "T__109", "T__110", "T__111", - "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", "HEX_INTEGER", - "BIN_INTEGER", "FLOAT_NUMBER", "FNUMBER", "STRING_ESCAPE_SEQ", "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", "T__109", "T__110", "T__111", + "LINECOMMENT", "COMMENT", "WS", "EOL", "NAME", "DEC_INTEGER", "HEX_INTEGER", + "BIN_INTEGER", "FLOAT_NUMBER", "FNUMBER", "STRING_ESCAPE_SEQ", "STRING", "INLINEASMBLOCK", "SINGLECHAR" }; } @@ -68,37 +68,37 @@ public class prog8Lexer extends Lexer { 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'", "'stack'", "'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'", + 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'", "'stack'", "'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, null, null, null, "LINECOMMENT", "COMMENT", "WS", "EOL", - "NAME", "DEC_INTEGER", "HEX_INTEGER", "BIN_INTEGER", "FLOAT_NUMBER", + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, 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" }; } @@ -181,7 +181,7 @@ public class prog8Lexer extends Lexer { // get rid of the enclosing quotes String s = getText(); setText(s.substring(1, s.length() - 1)); - + break; } } @@ -192,7 +192,7 @@ public class prog8Lexer extends Lexer { // get rid of the enclosing double braces String s = getText(); setText(s.substring(2, s.length() - 2)); - + break; } } @@ -203,7 +203,7 @@ public class prog8Lexer extends Lexer { // get rid of the enclosing quotes String s = getText(); setText(s.substring(1, s.length() - 1)); - + break; } } @@ -508,4 +508,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/parser/src/prog8/parser/prog8Parser.java similarity index 99% rename from compiler/src/prog8/parser/prog8Parser.java rename to parser/src/prog8/parser/prog8Parser.java index 87c7d8f86..61cb39738 100644 --- a/compiler/src/prog8/parser/prog8Parser.java +++ b/parser/src/prog8/parser/prog8Parser.java @@ -1,4 +1,4 @@ -// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7.2 +// Generated from /home/irmen/Projects/prog8/parser/antlr/prog8.g4 by ANTLR 4.7.2 package prog8.parser; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA;