mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
added bool to syntax files
This commit is contained in:
parent
1dfa8ee7d8
commit
9633c0b07a
@ -80,30 +80,6 @@ Optimizations:
|
||||
- when a for loop's loopvariable isn't referenced in the body, and the iterations are known, replace the loop by a repeatloop
|
||||
but we have no efficient way right now to see if the body references a variable.
|
||||
|
||||
BOOL data type?
|
||||
---------------
|
||||
Logical expressions now need to sprinkle boolean() calls on their operands to yield the correct boolean 0 or 1 result.
|
||||
This is inefficient because most of the time the operands already are boolean but the compiler doesn't know this
|
||||
because the type of boolean values is UBYTE (so theoretically the value can be anything from 0 - 255)
|
||||
|
||||
So the idea is to add a true 'bool' type
|
||||
|
||||
- add BOOL datatype to enumeration
|
||||
- optional (lot of work):
|
||||
- add BooleanLiteral ast node to hold true and false, of type BOOL
|
||||
- make 'true' and 'false' parse into BooleanLiterals
|
||||
- make sure everything works again (all places using NumericLiteral also have to consider BooleanLiteral...)
|
||||
- idea: let BooleanLiteral subclass from NumericLiteral ?
|
||||
- add 'bool' type to grammar and parser
|
||||
- remove builtin function boolean() replace with typecast to BOOL
|
||||
- logical expressions don't cast operands of BOOL type to BOOL anymore (is this done???)
|
||||
- before codegen, BOOL type is simply discarded and replaced by UBYTE
|
||||
|
||||
THE ABOVE HAS BEEN DONE
|
||||
|
||||
- rewrite: boolvar & 1 -> boolvar, (boolvar & 1 == 0) -> not boolvar
|
||||
- add ARRAY_OF_BOOL array type
|
||||
|
||||
|
||||
STRUCTS again?
|
||||
--------------
|
||||
|
@ -13,11 +13,11 @@
|
||||
</options>
|
||||
<keywords keywords="&;->;@;\$;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;%zeropage;%zpreserved;iso:;petscii:;sc:" />
|
||||
<keywords3 keywords="@requirezp;@shared;@zp;byte;const;float;str;ubyte;uword;void;word" />
|
||||
<keywords3 keywords="@requirezp;@shared;@zp;byte;const;float;str;ubyte;uword;bool;void;word" />
|
||||
<keywords4 keywords="abs;all;any;avg;callfar;callrom;cmp;len;lsb;memory;mkword;msb;peek;peekw;poke;pokew;pop;popw;push;pushw;reverse;rnd;rndw;rol;rol2;ror;ror2;rrestore;rrestorex;rsave;rsavex;sgn;sizeof;sort;sqrt16;swap;|>" />
|
||||
</highlighting>
|
||||
<extensionMap>
|
||||
<mapping ext="p8" />
|
||||
<mapping ext="prog8" />
|
||||
</extensionMap>
|
||||
</filetype>
|
||||
</filetype>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<Keywords name="Folders in comment, open"></Keywords>
|
||||
<Keywords name="Folders in comment, middle"></Keywords>
|
||||
<Keywords name="Folders in comment, close"></Keywords>
|
||||
<Keywords name="Keywords1">void const
str
byte ubyte
word uword
float
zp shared requirezp</Keywords>
|
||||
<Keywords name="Keywords1">void const
str
byte ubyte bool
word uword
float
zp shared requirezp</Keywords>
|
||||
<Keywords name="Keywords2">%address
%asm
%asmbinary
%asminclude
%breakpoint
%import
%launcher
%option
%output
%zeropage
%zpreserved</Keywords>
|
||||
<Keywords name="Keywords3">inline sub asmsub romsub
clobbers
asm
if
when else
if_cc if_cs if_eq if_mi if_neg if_nz if_pl if_pos if_vc if_vs if_z
for in step do while repeat
break return goto</Keywords>
|
||||
<Keywords name="Keywords4">abs all any avg callfar callrom cmp len lsb lsl lsr memory mkword msb peek peekw poke pokew push pushw pop popw rsave rsavex rrestore rrestorex reverse rnd rndw rol rol2 ror ror2 sgn sizeof sort sqrt16 swap</Keywords>
|
||||
|
@ -6,6 +6,7 @@
|
||||
; FIXME #31
|
||||
main {
|
||||
str input = "string literal\r\n\"\\"
|
||||
bool bb = false
|
||||
ubyte c = 'x' ; character literal in bold
|
||||
ubyte decimal = 0 + 1 - 2 * 3
|
||||
float pi = 3.1415
|
||||
|
@ -38,9 +38,9 @@ syn match prog8Directive "\(^\|\s\)%\(zpreserved\|address\|import\|option\)\>"
|
||||
syn match prog8Directive "\(^\|\s\)%\(asmbinary\|asminclude\|breakpoint\)\>"
|
||||
syn match prog8Directive "\(^\|\s\)%asm\>"
|
||||
|
||||
syn match prog8Type "\<\%(u\?byte\|u\?word\|float\|str\)\>"
|
||||
syn match prog8Type "\<\%(u\?byte\|u\?word\|float\|str\|bool\)\>"
|
||||
syn region prog8ArrayType matchgroup=prog8Type
|
||||
\ start="\<\%(u\?byte\|u\?word\|float\|str\)\[" end="\]"
|
||||
\ start="\<\%(u\?byte\|u\?word\|float\|str\|bool\)\[" end="\]"
|
||||
\ transparent
|
||||
syn keyword prog8StorageClass const
|
||||
syn match prog8StorageClass "\(^\|\s\)\(@zp\|@shared\|@requirezp\)\>"
|
||||
|
Loading…
Reference in New Issue
Block a user