NOP0 / rustmatic

PLC programming in Rust!
Apache License 2.0
35 stars 2 forks source link

Datatypes in grammar #14

Closed NOP0 closed 4 years ago

NOP0 commented 4 years ago

Just realized that some of the parse tests uses "INTEGER" as a datatype (mine included). As far as I know, this is not a valid 61131-3 datatype, the correct is "INT".

This is not a big deal to fix, but since datatypes are keywords, should these be added to the keywords section in the grammar?

Michael-F-Bryan commented 4 years ago

This is not a big deal to fix, but since datatypes are keywords

Are they actually keywords, or just the name of builtin types which can't be shadowed? Validation of identifiers (i.e. making sure you name a known type or don't define something twice) is normally pushed off to the semantic analysis layer. Often called the middle-end in a typical compiler.

NOP0 commented 4 years ago

Ok, I'm learning something every day. :slightly_smiling_face:

They're listed under keywords in the sense that you can't use these for user-defined elements (variable, typedef etc). But "keyword" might be a bit overloaded so it's different in the parsing sense.