identifiers can no longer start with an underscore. (this interfered with 64tass syntax)

This commit is contained in:
Irmen de Jong 2020-08-22 17:03:40 +02:00
parent 89f46222d9
commit 20cdcc673b
3 changed files with 25 additions and 46 deletions

View File

@ -157,7 +157,7 @@ Directives
Identifiers
-----------
Naming things in Prog8 is done via valid *identifiers*. They start with a letter or underscore,
Naming things in Prog8 is done via valid *identifiers*. They start with a letter,
and after that, a combination of letters, numbers, or underscores. Examples of valid identifiers::
a
@ -165,7 +165,7 @@ and after that, a combination of letters, numbers, or underscores. Examples of v
monkey
COUNTER
Better_Name_2
_something_strange_
something_strange__
Code blocks

View File

@ -5,54 +5,33 @@
main {
; todo make it possible to use cpu opcodes as varnames such as 'nop'
; todo make it possible to use cpu opcodes as varnames such as 'nop' by prefixing all asm vars with something such as '_'
sub start() {
byte ub
word uw
ubyte x = 1
ubyte z = 0
byte nop2
ubyte[] array = [1,2,3]
nop2=4
nop2++
foo.xxx()
ubyte i
ub = %00100001
for i in 0 to 9 {
c64scr.print_ubbin(ub as ubyte, true)
c64.CHROUT('\n')
;ub <<= 1
;ub <<= x
ub <<= (z+1)
}
derp:
goto main.nop2
main.nop2()
}
sub nop2 () {
c64.CHROUT('\n')
;ub = %11000110 ; -123
ub = -123
for i in 0 to 9 {
c64scr.print_ubbin(ub as ubyte, true)
c64.CHROUT('\n')
;ub >>= 1
;ub >>= x
ub >>= (z+1)
}
uw = %0011100000000011
for i in 0 to 17 {
c64scr.print_uwbin(uw as uword, true)
c64.CHROUT('\n')
;uw <<= 1
;uw <<= x
uw <<= (z+1)
}
c64.CHROUT('\n')
uw = -12345
;uw = %1110000011000100
for i in 0 to 17 {
c64scr.print_uwbin(uw as uword, true)
c64.CHROUT('\n')
;uw >>= 1
;uw >>= x
uw >>= (z+1)
}
}
}
foo {
sub xxx() {
bar:
goto bar
}
}

View File

@ -20,7 +20,7 @@ WS : [ \t] -> skip ;
EOL : [\r\n]+ ;
// WS2 : '\\' EOL -> skip;
VOID: 'void';
NAME : [a-zA-Z_][a-zA-Z0-9_]* ;
NAME : [a-zA-Z][a-zA-Z0-9_]* ;
DEC_INTEGER : ('0'..'9') | (('1'..'9')('0'..'9')+);
HEX_INTEGER : '$' (('a'..'f') | ('A'..'F') | ('0'..'9'))+ ;
BIN_INTEGER : '%' ('0' | '1')+ ;