cwfitzgerald / rockstar-webpiler

A WIP Rockstar Compiler on the Web
https://rockstar.connorwfitzgerald.com/
MIT License
8 stars 1 forks source link

reserved words handled in assignments? #1

Closed Rifhutch closed 6 years ago

Rifhutch commented 6 years ago

Consider the poetic assignment my girl is without

It looks like 'without' is being read as a (non-reserved) 7 letter word.

But reserved words I believe should be resolved to their aliases (in this case '-') which isn't alphabetical, so the result would just be a poetic numeric assignment based on a 0 length string? Admittedly, the case where the right hand side is a reserved word could be a little clearer in the spec.

cwfitzgerald commented 6 years ago

As far as I can tell, this is the correct behavior according to the spec. I have clipped the relevant lines:

For the keywords true, false, nothing, nobody and nowhere, a poetic assignment is a single line consisting of a variable name, the is keyword and the required value literal

A poetic string literal assignment starts with a variable name, followed by one of the keywords says followed by a single space. The rest of the line up to the \n terminator is treated as an unquoted string literal.

This makes it clear that those 5 things are the only things allowed after is that isn't a numeric literal. I'm actually more generous than the spec, I will give you any of the true, false, null, or mysterious aliases for their values. Without is an alias for minus which, as this is (and cannot be) part of a math expression, isn't needed to be replaced.

A note on the replacement with -, that's a implementation detail of rockstar-py.

cwfitzgerald commented 6 years ago

See https://github.com/cwfitzgerald/rockstar-webpiler/blob/master/shared/src/main/scala/rockstar/parser.scala#L296

cwfitzgerald commented 6 years ago

From what I can tell, this is actually a bug in rockstar-py, I can file it :)

yyyyyyyan commented 6 years ago

Not a bug, the specs are clear

cwfitzgerald commented 6 years ago

Resolved in https://github.com/dylanbeattie/rockstar/pull/117