irmen / prog8

high level programming language and compiler targeting 6502 machines such as the C-64 and CommanderX16
https://prog8.readthedocs.io/
Other
152 stars 18 forks source link

parse error: no viable alternative at input 'not in' Where as, this does not: #115

Closed oodler577 closed 11 months ago

oodler577 commented 11 months ago

Reproduce,

%import textio
%zeropage basicsafe

main {
    sub start() {
        while 1 {
            ubyte insyncChar = cbm.GETIN()
            if insyncChar == $1b {
                break
            }
            if not insyncChar {
                break 
            }
        }
    }
}

However, the following works:

%import textio
%zeropage basicsafe

main {
    sub start() {
        while 1 {
            ubyte NsyncChar = cbm.GETIN()
            if NsyncChar == $1b {
                break
            }
            if not NsyncChar {
                break 
            }
        }
    }
}

if not insyncChar seems to be creating a parsing error

irmen commented 11 months ago

I guess me using "not in" as a segment in the grammar file wasn't the best choice.

oodler577 commented 11 months ago

Is "not in " an option?

irmen commented 11 months ago

It's a containment test operator, the inverse of in. It checks if a byte is not in a string, for example. You could also write not(x in y) but x not in y reads nicer.