removed %target directive (didn't add much, too confusing, only supported single target)

This commit is contained in:
Irmen de Jong 2021-09-04 15:01:16 +02:00
parent d9ab2f8b90
commit fd1f30f92b
46 changed files with 40 additions and 102 deletions

View File

@ -4,7 +4,6 @@
;
; indent format: TABS, size=8
%target c64
%option enable_floats
floats {

View File

@ -1,4 +1,3 @@
%target c64
%import textio
; bitmap pixel graphics module for the C64

View File

@ -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

View File

@ -4,7 +4,6 @@
;
; indent format: TABS, size=8
%target c64
%import syslib
%import conv

View File

@ -4,7 +4,6 @@
;
; indent format: TABS, size=8
%target cx16
%option enable_floats
floats {

View File

@ -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)

View File

@ -1,4 +1,3 @@
%target cx16
%import syslib
%import textio

View File

@ -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.

View File

@ -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) ----

View File

@ -4,7 +4,6 @@
;
; indent format: TABS, size=8
%target cx16
%import syslib
%import conv

View File

@ -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)

View File

@ -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) }

View File

@ -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<Directive>()
importedModule.statements.removeAll(directives)
directives = directives.filter{ it.directive !in moduleLevelDirectives }

View File

@ -33,13 +33,6 @@ This makes it easier to understand and relate the generated code. Examples::
Directives
-----------
.. data:: %target <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 <type>
Level: module.

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%import textio
%import test_stack

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%import textio
%zeropage basicsafe

View File

@ -1,4 +1,3 @@
%target c64
%import textio
%import syslib

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%import textio
%zeropage basicsafe

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%import textio
%import test_stack

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%import test_stack
%import textio

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
%import palette
%import string

View File

@ -1,4 +1,3 @@
%target cx16
%import palette
%import conv
%import textio

View File

@ -1,4 +1,3 @@
%target cx16
%import syslib
%import test_stack
%import conv

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
main {

View File

@ -1,6 +1,5 @@
; CommanderX16 text datetime example!
%target cx16
%import textio
%zeropage basicsafe

View File

@ -1,4 +1,3 @@
%target cx16
%import gfx2
%import floats
%import textio

View File

@ -1,4 +1,3 @@
%target cx16
%import palette
%option no_sysinit

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
%import floats
%zeropage basicsafe

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
%import floats
%zeropage basicsafe

View File

@ -1,4 +1,3 @@
%target cx16
%import palette
%import gfx2
%option no_sysinit

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
%import palette

View File

@ -8,7 +8,6 @@
; simplistic sound effects (Vera PSG)
%target cx16
%import syslib
%import textio
%import test_stack

View File

@ -1,4 +1,3 @@
%target cx16
%import gfx2
%import textio
%import test_stack

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
%option no_sysinit
%zeropage basicsafe

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%import test_stack
%import textio

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
main {

View File

@ -1,4 +1,3 @@
%target c64
%import textio
%import syslib
%zeropage basicsafe

View File

@ -8,7 +8,6 @@
; some simple sound effects
%target c64
%import syslib
%import textio
%import test_stack

View File

@ -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()
; }
}

View File

@ -1,4 +1,3 @@
%target c64
%import floats
%import graphics
%import test_stack

View File

@ -1,4 +1,3 @@
%target c64
%import syslib
%zeropage basicsafe

View File

@ -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)*)
;

View File

@ -12,7 +12,7 @@
<option name="HAS_STRING_ESCAPES" value="true" />
</options>
<keywords keywords="&amp;;-&gt;;@;\$;and;as;asmsub;break;clobbers;do;downto;else;false;for;goto;if;if_cc;if_cs;if_eq;if_mi;if_ne;if_neg;if_nz;if_pl;if_pos;if_vc;if_vs;if_z;in;inline;not;or;repeat;return;romsub;step;sub;to;true;until;when;while;xor;~" ignore_case="false" />
<keywords2 keywords="%address;%asm;%asmbinary;%asminclude;%breakpoint;%import;%launcher;%option;%output;%target;%zeropage;%zpreserved" />
<keywords2 keywords="%address;%asm;%asmbinary;%asminclude;%breakpoint;%import;%launcher;%option;%output;%zeropage;%zpreserved" />
<keywords3 keywords="byte;const;float;shared;str;ubyte;uword;void;word;zp" />
<keywords4 keywords="abs;acos;all;any;asin;atan;avg;callfar;callrom;ceil;cmp;cos;cos16;cos16u;cos8;cos8u;deg;floor;len;ln;log2;lsb;lsl;lsr;max;memory;min;mkword;msb;peek;peekw;poke;pokew;rad;reverse;rnd;rndf;rndw;rol;rol2;ror;ror2;round;sgn;sin;sin16;sin16u;sin8;sin8u;sizeof;sort;sqrt;sqrt16;sum;swap;tan" />
</highlighting>
@ -20,4 +20,4 @@
<mapping ext="p8" />
<mapping ext="prog8" />
</extensionMap>
</filetype>
</filetype>

View File

@ -25,7 +25,7 @@
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1">void const&#x000D;&#x000A;str&#x000D;&#x000A;byte ubyte&#x000D;&#x000A;word uword&#x000D;&#x000A;float&#x000D;&#x000A;zp shared</Keywords>
<Keywords name="Keywords2">%address&#x000D;&#x000A;%asm&#x000D;&#x000A;%asmbinary&#x000D;&#x000A;%asminclude&#x000D;&#x000A;%breakpoint&#x000D;&#x000A;%import&#x000D;&#x000A;%launcher&#x000D;&#x000A;%option&#x000D;&#x000A;%output&#x000D;&#x000A;%target&#x000D;&#x000A;%zeropage&#x000D;&#x000A;%zpreserved</Keywords>
<Keywords name="Keywords2">%address&#x000D;&#x000A;%asm&#x000D;&#x000A;%asmbinary&#x000D;&#x000A;%asminclude&#x000D;&#x000A;%breakpoint&#x000D;&#x000A;%import&#x000D;&#x000A;%launcher&#x000D;&#x000A;%option&#x000D;&#x000A;%output&#x000D;&#x000A;%zeropage&#x000D;&#x000A;%zpreserved</Keywords>
<Keywords name="Keywords3">inline sub asmsub romsub&#x000D;&#x000A;clobbers&#x000D;&#x000A;asm&#x000D;&#x000A;if&#x000D;&#x000A;when else&#x000D;&#x000A;if_cc if_cs if_eq if_mi if_neg if_nz if_pl if_pos if_vc if_vs if_z&#x000D;&#x000A;for in step do while repeat&#x000D;&#x000A;break return goto</Keywords>
<Keywords name="Keywords4">abs acos all any asin atan avg callfar callrom ceil cmp cos cos16 cos16u cos8 cos8u deg floor len ln log2 lsb lsl lsr max memory min mkword msb peek peekw poke pokew rad reverse rnd rndf rndw rol rol2 ror ror2 round sgn sin sin16 sin16u sin8 sin8u sizeof sort sqrt sqrt16 sum swap tan&#x000D;&#x000A;</Keywords>
<Keywords name="Keywords5">true false&#x000D;&#x000A;not and or xor&#x000D;&#x000A;as to downto</Keywords>

View File

@ -1,4 +1,3 @@
%target cx16
%import textio
%zeropage basicsafe
%option no_sysinit

View File

@ -33,7 +33,7 @@ syn keyword prog8Repeat for while in do until repeat
syn match prog8Label "\<\w\+\>:"
syn keyword prog8Operator and or to downto as void
syn match prog8Directive "\(^\|\s\)%\(target\|output\|launcher\|zeropage\)\>"
syn match prog8Directive "\(^\|\s\)%\(output\|launcher\|zeropage\)\>"
syn match prog8Directive "\(^\|\s\)%\(zpreserved\|address\|import\|option\)\>"
syn match prog8Directive "\(^\|\s\)%\(asmbinary\|asminclude\|breakpoint\)\>"
syn match prog8Directive "\(^\|\s\)%asm\>"