Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment operator parse errors for object properties #173

Closed
TwitchBronBron opened this issue Feb 25, 2019 · 1 comment · Fixed by #189
Closed

Assignment operator parse errors for object properties #173

TwitchBronBron opened this issue Feb 25, 2019 · 1 comment · Fixed by #189
Labels
bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior parser Affects this project's token parser

Comments

@TwitchBronBron
Copy link
Contributor

TwitchBronBron commented Feb 25, 2019

Assignment operators do not work when used against an object property. Here is a test file that compiles and runs on Roku, but produces parse errors in brs.

image

Source

function Main()
   m.age = 1

   m.age += 1
   m.age -= 1
   m.age *= 1
   m.age /= 1
   m.age \= 1
   m.age <<= 1
   m.age >>= 1

   m["age"] += 1
   m["age"] -= 1
   m["age"] *= 1
   m["age"] /= 1
   m["age"] \= 1
   m["age"] <<= 1
   m["age"] >>= 1

   print m.age
end function

@sjbarag sjbarag added bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior parser Affects this project's token parser labels Feb 26, 2019
sjbarag added a commit that referenced this issue Mar 7, 2019
Due to the fact that the `=` token is ambiguous without context (i.e.
"is it an assignment or comparison?"), assignments get parsed as binary
operations and transformed into assignments after the binary operation's
been completely parsed.  Dotted and indexed "set" statements (e.g.
`foo.bar = "baz"`) required a bit of additional parsing logic when they
were added.  Since assignment operators like `+=` are unambiguously used
in statements only, there was yet more parsing logic required to handle
assignment operators when the left-hand side is a dotted or indexed set.

This should take care of it though!

fixes #173
@TwitchBronBron
Copy link
Contributor Author

TwitchBronBron commented Mar 8, 2019

This appears to be working great except for the bitshift assignment operators, which still cause parse errors. I'm sure that's related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior parser Affects this project's token parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants