From d9ab2f8b906fd1eb43132d71851902b79f66caa6 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 3 Sep 2021 23:00:00 +0200 Subject: [PATCH 01/17] upgrade to kotlin 1.5.30 --- build.gradle | 2 +- compilerAst/test/TestAntlrParser.kt | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index c122ddb22..b048f783a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,3 @@ plugins { - id "org.jetbrains.kotlin.jvm" version "1.5.20" apply false + id "org.jetbrains.kotlin.jvm" version "1.5.30" apply false } diff --git a/compilerAst/test/TestAntlrParser.kt b/compilerAst/test/TestAntlrParser.kt index bb90bfb34..9a7868a3d 100644 --- a/compilerAst/test/TestAntlrParser.kt +++ b/compilerAst/test/TestAntlrParser.kt @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test import prog8.ast.IBuiltinFunctions import prog8.ast.IMemSizer import prog8.ast.IStringEncoding -import prog8.ast.Program import prog8.ast.antlr.toAst import prog8.ast.base.DataType import prog8.ast.base.Position @@ -14,9 +13,13 @@ import prog8.ast.expressions.Expression import prog8.ast.expressions.InferredTypes import prog8.ast.expressions.NumericLiteralValue import prog8.ast.statements.Block -import prog8.parser.* +import prog8.parser.ParsingFailedError +import prog8.parser.prog8Lexer +import prog8.parser.prog8Parser import java.nio.file.Path -import kotlin.test.* +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertIs class TestAntlrParser { From fd1f30f92b8d02734c83c603d63ca90467b56161 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 4 Sep 2021 15:01:16 +0200 Subject: [PATCH 02/17] removed %target directive (didn't add much, too confusing, only supported single target) --- compiler/res/prog8lib/c64/floats.p8 | 1 - compiler/res/prog8lib/c64/graphics.p8 | 1 - compiler/res/prog8lib/c64/syslib.p8 | 2 - compiler/res/prog8lib/c64/textio.p8 | 1 - compiler/res/prog8lib/cx16/floats.p8 | 1 - compiler/res/prog8lib/cx16/gfx2.p8 | 2 - compiler/res/prog8lib/cx16/graphics.p8 | 1 - compiler/res/prog8lib/cx16/palette.p8 | 2 - compiler/res/prog8lib/cx16/syslib.p8 | 3 - compiler/res/prog8lib/cx16/textio.p8 | 1 - .../compiler/astprocessing/AstChecker.kt | 8 --- .../astprocessing/AstIdentifiersChecker.kt | 10 --- compilerAst/src/prog8/parser/ModuleParsing.kt | 2 +- docs/source/syntaxreference.rst | 7 --- examples/balloonflight.p8 | 1 - examples/bdmusic-irq.p8 | 1 - examples/bdmusic.p8 | 1 - examples/charset.p8 | 1 - examples/cube3d-sprites.p8 | 1 - examples/cube3d.p8 | 1 - examples/cx16/amiga.p8 | 1 - examples/cx16/bobs.p8 | 1 - examples/cx16/cobramk3-gfx.p8 | 1 - examples/cx16/cube3d.p8 | 1 - examples/cx16/datetime.p8 | 1 - examples/cx16/highresbitmap.p8 | 1 - examples/cx16/kefrenbars.p8 | 1 - examples/cx16/mandelbrot-gfx-colors.p8 | 1 - examples/cx16/mandelbrot.p8 | 1 - examples/cx16/multipalette.p8 | 1 - examples/cx16/rasterbars.p8 | 1 - examples/cx16/tehtriz.p8 | 1 - examples/cx16/testgfx2.p8 | 1 - examples/cx16/vtui/testvtui.p8 | 1 - examples/plasma.p8 | 1 - examples/rasterbars.p8 | 1 - examples/sprites.p8 | 1 - examples/tehtriz.p8 | 1 - examples/test.p8 | 63 ++++++++++--------- examples/turtle-gfx.p8 | 1 - examples/wizzine.p8 | 1 - parser/antlr/prog8.g4 | 2 +- syntax-files/IDEA/Prog8.xml | 4 +- syntax-files/NotepadPlusPlus/Prog8.xml | 2 +- syntax-files/NotepadPlusPlus/syntax-test.p8 | 1 - syntax-files/Vim/prog8.vim | 2 +- 46 files changed, 40 insertions(+), 102 deletions(-) diff --git a/compiler/res/prog8lib/c64/floats.p8 b/compiler/res/prog8lib/c64/floats.p8 index 7d8ee5d29..417e9faf5 100644 --- a/compiler/res/prog8lib/c64/floats.p8 +++ b/compiler/res/prog8lib/c64/floats.p8 @@ -4,7 +4,6 @@ ; ; indent format: TABS, size=8 -%target c64 %option enable_floats floats { diff --git a/compiler/res/prog8lib/c64/graphics.p8 b/compiler/res/prog8lib/c64/graphics.p8 index 4593cf563..c41e3d6f4 100644 --- a/compiler/res/prog8lib/c64/graphics.p8 +++ b/compiler/res/prog8lib/c64/graphics.p8 @@ -1,4 +1,3 @@ -%target c64 %import textio ; bitmap pixel graphics module for the C64 diff --git a/compiler/res/prog8lib/c64/syslib.p8 b/compiler/res/prog8lib/c64/syslib.p8 index 56cce7440..da7358b8c 100644 --- a/compiler/res/prog8lib/c64/syslib.p8 +++ b/compiler/res/prog8lib/c64/syslib.p8 @@ -5,8 +5,6 @@ ; ; indent format: TABS, size=8 -%target c64 - c64 { &ubyte TIME_HI = $a0 ; software jiffy clock, hi byte &ubyte TIME_MID = $a1 ; .. mid byte diff --git a/compiler/res/prog8lib/c64/textio.p8 b/compiler/res/prog8lib/c64/textio.p8 index 661403f8e..118d3fa71 100644 --- a/compiler/res/prog8lib/c64/textio.p8 +++ b/compiler/res/prog8lib/c64/textio.p8 @@ -4,7 +4,6 @@ ; ; indent format: TABS, size=8 -%target c64 %import syslib %import conv diff --git a/compiler/res/prog8lib/cx16/floats.p8 b/compiler/res/prog8lib/cx16/floats.p8 index 9400a2af2..a9a0df938 100644 --- a/compiler/res/prog8lib/cx16/floats.p8 +++ b/compiler/res/prog8lib/cx16/floats.p8 @@ -4,7 +4,6 @@ ; ; indent format: TABS, size=8 -%target cx16 %option enable_floats floats { diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 4842a2f02..37fdf6eba 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -1,5 +1,3 @@ -%target cx16 - ; Bitmap pixel graphics routines for the CommanderX16 ; Custom routines to use the full-screen 640x480 and 320x240 screen modes. ; (These modes are not supported by the documented GRAPH_xxxx kernal routines) diff --git a/compiler/res/prog8lib/cx16/graphics.p8 b/compiler/res/prog8lib/cx16/graphics.p8 index 09679bff0..f8cb55b1f 100644 --- a/compiler/res/prog8lib/cx16/graphics.p8 +++ b/compiler/res/prog8lib/cx16/graphics.p8 @@ -1,4 +1,3 @@ -%target cx16 %import syslib %import textio diff --git a/compiler/res/prog8lib/cx16/palette.p8 b/compiler/res/prog8lib/cx16/palette.p8 index 4a4e184e0..75073f136 100644 --- a/compiler/res/prog8lib/cx16/palette.p8 +++ b/compiler/res/prog8lib/cx16/palette.p8 @@ -1,5 +1,3 @@ -%target cx16 - ; Manipulate the Commander X16's display color palette. ; Should you want to restore the default palette, you have to reinitialize the Vera yourself. diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index e125f9a99..8fa4ea50b 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -5,9 +5,6 @@ ; ; indent format: TABS, size=8 -%target cx16 - - c64 { ; ---- kernal routines, these are the same as on the Commodore-64 (hence the same block name) ---- diff --git a/compiler/res/prog8lib/cx16/textio.p8 b/compiler/res/prog8lib/cx16/textio.p8 index 79c071ba8..9b2915264 100644 --- a/compiler/res/prog8lib/cx16/textio.p8 +++ b/compiler/res/prog8lib/cx16/textio.p8 @@ -4,7 +4,6 @@ ; ; indent format: TABS, size=8 -%target cx16 %import syslib %import conv diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index ea184b71f..07259b4aa 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -714,14 +714,6 @@ internal class AstChecker(private val program: Program, else if(directive.args.map{it.name in setOf("enable_floats", "force_output", "no_sysinit", "align_word", "align_page")}.any { !it }) err("invalid option directive argument(s)") } - "%target" -> { - if(directive.parent !is Block && directive.parent !is Module) - err("this directive may only occur in a block or at module level") - if(directive.args.size != 1) - err("directive requires one argument") - if(directive.args.single().name !in setOf(C64Target.name, Cx16Target.name)) - err("invalid compilation target") - } else -> throw SyntaxError("invalid directive ${directive.directive}", directive.position) } super.visit(directive) diff --git a/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt index f9f173ce2..00ba76541 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt @@ -33,16 +33,6 @@ internal class AstIdentifiersChecker(private val program: Program, private val e super.visit(block) } - override fun visit(directive: Directive) { - if(directive.directive=="%target") { - val compatibleTarget = directive.args.single().name - if (compatibleTarget != compTarget.name) - errors.err("module's compilation target ($compatibleTarget) differs from active target (${compTarget.name})", directive.position) - } - - super.visit(directive) - } - override fun visit(decl: VarDecl) { decl.datatypeErrors.forEach { errors.err(it.message, it.position) } diff --git a/compilerAst/src/prog8/parser/ModuleParsing.kt b/compilerAst/src/prog8/parser/ModuleParsing.kt index 94faa6ee4..f927ae7ca 100644 --- a/compilerAst/src/prog8/parser/ModuleParsing.kt +++ b/compilerAst/src/prog8/parser/ModuleParsing.kt @@ -135,7 +135,7 @@ class ModuleImporter(private val program: Program, private fun removeDirectivesFromImportedModule(importedModule: Module) { // Most global directives don't apply for imported modules, so remove them - val moduleLevelDirectives = listOf("%output", "%launcher", "%zeropage", "%zpreserved", "%address", "%target") + val moduleLevelDirectives = listOf("%output", "%launcher", "%zeropage", "%zpreserved", "%address") var directives = importedModule.statements.filterIsInstance() importedModule.statements.removeAll(directives) directives = directives.filter{ it.directive !in moduleLevelDirectives } diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 2b1e52fb5..e403afe8b 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -33,13 +33,6 @@ This makes it easier to understand and relate the generated code. Examples:: Directives ----------- -.. data:: %target - - Level: module. - Global setting, specifies that this module can only work for the given compiler target. - If compiled with a different target, compilation is aborted with an error message. - - .. data:: %output Level: module. diff --git a/examples/balloonflight.p8 b/examples/balloonflight.p8 index a39eac281..eb82e46bb 100644 --- a/examples/balloonflight.p8 +++ b/examples/balloonflight.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %import textio %import test_stack diff --git a/examples/bdmusic-irq.p8 b/examples/bdmusic-irq.p8 index 2bb1fb30c..6ed3b0e0f 100644 --- a/examples/bdmusic-irq.p8 +++ b/examples/bdmusic-irq.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %import textio %zeropage basicsafe diff --git a/examples/bdmusic.p8 b/examples/bdmusic.p8 index 29b443e38..b96bb83c7 100644 --- a/examples/bdmusic.p8 +++ b/examples/bdmusic.p8 @@ -1,4 +1,3 @@ -%target c64 %import textio %import syslib diff --git a/examples/charset.p8 b/examples/charset.p8 index 84214def7..71f10e252 100644 --- a/examples/charset.p8 +++ b/examples/charset.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %import textio %zeropage basicsafe diff --git a/examples/cube3d-sprites.p8 b/examples/cube3d-sprites.p8 index 843d6f81f..46091e3e3 100644 --- a/examples/cube3d-sprites.p8 +++ b/examples/cube3d-sprites.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %import textio %import test_stack diff --git a/examples/cube3d.p8 b/examples/cube3d.p8 index 65fd9b2e0..44c6cb45b 100644 --- a/examples/cube3d.p8 +++ b/examples/cube3d.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %import test_stack %import textio diff --git a/examples/cx16/amiga.p8 b/examples/cx16/amiga.p8 index ddaf57713..47cd11496 100644 --- a/examples/cx16/amiga.p8 +++ b/examples/cx16/amiga.p8 @@ -1,4 +1,3 @@ -%target cx16 %import textio %import palette %import string diff --git a/examples/cx16/bobs.p8 b/examples/cx16/bobs.p8 index f4954e8c3..d15ed0f79 100644 --- a/examples/cx16/bobs.p8 +++ b/examples/cx16/bobs.p8 @@ -1,4 +1,3 @@ -%target cx16 %import palette %import conv %import textio diff --git a/examples/cx16/cobramk3-gfx.p8 b/examples/cx16/cobramk3-gfx.p8 index 2884f0dc3..c72abbcf1 100644 --- a/examples/cx16/cobramk3-gfx.p8 +++ b/examples/cx16/cobramk3-gfx.p8 @@ -1,4 +1,3 @@ -%target cx16 %import syslib %import test_stack %import conv diff --git a/examples/cx16/cube3d.p8 b/examples/cx16/cube3d.p8 index d4b8a3d37..149e0e7fb 100644 --- a/examples/cx16/cube3d.p8 +++ b/examples/cx16/cube3d.p8 @@ -1,4 +1,3 @@ -%target cx16 %import textio main { diff --git a/examples/cx16/datetime.p8 b/examples/cx16/datetime.p8 index 0fa4887b4..8a4e40dd1 100644 --- a/examples/cx16/datetime.p8 +++ b/examples/cx16/datetime.p8 @@ -1,6 +1,5 @@ ; CommanderX16 text datetime example! -%target cx16 %import textio %zeropage basicsafe diff --git a/examples/cx16/highresbitmap.p8 b/examples/cx16/highresbitmap.p8 index 49d042e60..4a0f536d1 100644 --- a/examples/cx16/highresbitmap.p8 +++ b/examples/cx16/highresbitmap.p8 @@ -1,4 +1,3 @@ -%target cx16 %import gfx2 %import floats %import textio diff --git a/examples/cx16/kefrenbars.p8 b/examples/cx16/kefrenbars.p8 index a3c6ce6be..0b7b31306 100644 --- a/examples/cx16/kefrenbars.p8 +++ b/examples/cx16/kefrenbars.p8 @@ -1,4 +1,3 @@ -%target cx16 %import palette %option no_sysinit diff --git a/examples/cx16/mandelbrot-gfx-colors.p8 b/examples/cx16/mandelbrot-gfx-colors.p8 index 844faaef5..b386ee7de 100644 --- a/examples/cx16/mandelbrot-gfx-colors.p8 +++ b/examples/cx16/mandelbrot-gfx-colors.p8 @@ -1,4 +1,3 @@ -%target cx16 %import textio %import floats %zeropage basicsafe diff --git a/examples/cx16/mandelbrot.p8 b/examples/cx16/mandelbrot.p8 index a92e46529..58a1d5dba 100644 --- a/examples/cx16/mandelbrot.p8 +++ b/examples/cx16/mandelbrot.p8 @@ -1,4 +1,3 @@ -%target cx16 %import textio %import floats %zeropage basicsafe diff --git a/examples/cx16/multipalette.p8 b/examples/cx16/multipalette.p8 index a4801d102..28fe57af8 100644 --- a/examples/cx16/multipalette.p8 +++ b/examples/cx16/multipalette.p8 @@ -1,4 +1,3 @@ -%target cx16 %import palette %import gfx2 %option no_sysinit diff --git a/examples/cx16/rasterbars.p8 b/examples/cx16/rasterbars.p8 index df73756bc..94b2bf4b2 100644 --- a/examples/cx16/rasterbars.p8 +++ b/examples/cx16/rasterbars.p8 @@ -1,4 +1,3 @@ -%target cx16 %import textio %import palette diff --git a/examples/cx16/tehtriz.p8 b/examples/cx16/tehtriz.p8 index a33473236..32cfc5ff7 100644 --- a/examples/cx16/tehtriz.p8 +++ b/examples/cx16/tehtriz.p8 @@ -8,7 +8,6 @@ ; simplistic sound effects (Vera PSG) -%target cx16 %import syslib %import textio %import test_stack diff --git a/examples/cx16/testgfx2.p8 b/examples/cx16/testgfx2.p8 index be8b2a8d9..6317aaa76 100644 --- a/examples/cx16/testgfx2.p8 +++ b/examples/cx16/testgfx2.p8 @@ -1,4 +1,3 @@ -%target cx16 %import gfx2 %import textio %import test_stack diff --git a/examples/cx16/vtui/testvtui.p8 b/examples/cx16/vtui/testvtui.p8 index b161e1503..9eb1f6440 100644 --- a/examples/cx16/vtui/testvtui.p8 +++ b/examples/cx16/vtui/testvtui.p8 @@ -1,4 +1,3 @@ -%target cx16 %import textio %option no_sysinit %zeropage basicsafe diff --git a/examples/plasma.p8 b/examples/plasma.p8 index 9c1eaf37e..094765a82 100644 --- a/examples/plasma.p8 +++ b/examples/plasma.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %import test_stack %import textio diff --git a/examples/rasterbars.p8 b/examples/rasterbars.p8 index 6057810de..505cc1d16 100644 --- a/examples/rasterbars.p8 +++ b/examples/rasterbars.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib main { diff --git a/examples/sprites.p8 b/examples/sprites.p8 index d336e6a65..b15f92efd 100644 --- a/examples/sprites.p8 +++ b/examples/sprites.p8 @@ -1,4 +1,3 @@ -%target c64 %import textio %import syslib %zeropage basicsafe diff --git a/examples/tehtriz.p8 b/examples/tehtriz.p8 index 3fdffd868..5f75d330f 100644 --- a/examples/tehtriz.p8 +++ b/examples/tehtriz.p8 @@ -8,7 +8,6 @@ ; some simple sound effects -%target c64 %import syslib %import textio %import test_stack diff --git a/examples/test.p8 b/examples/test.p8 index 860fab040..d84387a30 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,38 +5,43 @@ main { label: sub start() { - sub2(&label) - sub2(&label_local) - sub2(&main.sub2.label_in_sub2) - uword xx = &label_local - txt.print_uwhex(xx, true) - txt.nl() - xx = &label - txt.print_uwhex(xx, true) - txt.nl() - xx = &main.label - txt.print_uwhex(xx, true) - txt.nl() - xx = &main.sub2.label_in_sub2 - txt.print_uwhex(xx, true) - txt.nl() - xx = main.sub2.sub2var - txt.print_uwhex(xx, true) - txt.nl() - xx = &main.start.label_local - txt.print_uwhex(xx, true) - txt.nl() + + txt.print("hey\n") + %breakpoint + txt.print("hey2\n") + +; sub2(&label) +; sub2(&label_local) +; sub2(&main.sub2.label_in_sub2) +; uword xx = &label_local +; txt.print_uwhex(xx, true) +; txt.nl() +; xx = &label +; txt.print_uwhex(xx, true) +; txt.nl() +; xx = &main.label +; txt.print_uwhex(xx, true) +; txt.nl() +; xx = &main.sub2.label_in_sub2 +; txt.print_uwhex(xx, true) +; txt.nl() +; xx = main.sub2.sub2var +; txt.print_uwhex(xx, true) +; txt.nl() +; xx = &main.start.label_local +; txt.print_uwhex(xx, true) +; txt.nl() label_local: return } - sub sub2(uword ad) { - uword sub2var = 42 - - txt.print_uwhex(ad,true) - txt.nl() -label_in_sub2: - txt.nl() - } +; sub sub2(uword ad) { +; uword sub2var = 42 +; +; txt.print_uwhex(ad,true) +; txt.nl() +;label_in_sub2: +; txt.nl() +; } } diff --git a/examples/turtle-gfx.p8 b/examples/turtle-gfx.p8 index bfefa7115..f3bf3224c 100644 --- a/examples/turtle-gfx.p8 +++ b/examples/turtle-gfx.p8 @@ -1,4 +1,3 @@ -%target c64 %import floats %import graphics %import test_stack diff --git a/examples/wizzine.p8 b/examples/wizzine.p8 index f50946f07..0af5abb4e 100644 --- a/examples/wizzine.p8 +++ b/examples/wizzine.p8 @@ -1,4 +1,3 @@ -%target c64 %import syslib %zeropage basicsafe diff --git a/parser/antlr/prog8.g4 b/parser/antlr/prog8.g4 index 9a2cc4fe4..e43e8f81b 100644 --- a/parser/antlr/prog8.g4 +++ b/parser/antlr/prog8.g4 @@ -135,7 +135,7 @@ unconditionaljump : 'goto' (integerliteral | scoped_identifier) ; directive : directivename=('%output' | '%launcher' | '%zeropage' | '%zpreserved' | '%address' | '%import' | - '%breakpoint' | '%asminclude' | '%asmbinary' | '%option' | '%target' ) + '%breakpoint' | '%asminclude' | '%asmbinary' | '%option' ) (directivearg? | directivearg (',' directivearg)*) ; diff --git a/syntax-files/IDEA/Prog8.xml b/syntax-files/IDEA/Prog8.xml index 0b5629951..6b7feb46e 100644 --- a/syntax-files/IDEA/Prog8.xml +++ b/syntax-files/IDEA/Prog8.xml @@ -12,7 +12,7 @@