diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 22449c534..6f61f45fd 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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? -------------- diff --git a/syntax-files/IDEA/Prog8.xml b/syntax-files/IDEA/Prog8.xml index ffe55eb04..f10780578 100644 --- a/syntax-files/IDEA/Prog8.xml +++ b/syntax-files/IDEA/Prog8.xml @@ -13,11 +13,11 @@ - + - \ No newline at end of file + diff --git a/syntax-files/NotepadPlusPlus/Prog8.xml b/syntax-files/NotepadPlusPlus/Prog8.xml index 7fb7a9b13..df8c304a6 100644 --- a/syntax-files/NotepadPlusPlus/Prog8.xml +++ b/syntax-files/NotepadPlusPlus/Prog8.xml @@ -24,7 +24,7 @@ - void const str byte ubyte word uword float zp shared requirezp + void const str byte ubyte bool word uword float zp shared requirezp %address %asm %asmbinary %asminclude %breakpoint %import %launcher %option %output %zeropage %zpreserved 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 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 diff --git a/syntax-files/NotepadPlusPlus/syntax-test.p8 b/syntax-files/NotepadPlusPlus/syntax-test.p8 index a64982a25..a28e15633 100644 --- a/syntax-files/NotepadPlusPlus/syntax-test.p8 +++ b/syntax-files/NotepadPlusPlus/syntax-test.p8 @@ -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 diff --git a/syntax-files/Vim/prog8.vim b/syntax-files/Vim/prog8.vim index 53a629f13..60dfae591 100644 --- a/syntax-files/Vim/prog8.vim +++ b/syntax-files/Vim/prog8.vim @@ -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\)\>"