MerlinofMines / EasyCommands

Github Repository for Ingame Scripts built by MerlinofMines. Uses MDK to Deploy to SpaceEngineerse
GNU General Public License v3.0
8 stars 3 forks source link

[Bug] Incorrect Selector & String Parsing #233

Closed MerlinofMines closed 2 years ago

MerlinofMines commented 2 years ago

Describe the bug There are a couple parsing issues when trying to set selector values to a string when the string being set includes a block type keyword.

To Reproduce

set myList to []
set myList["thing"] to "My Drill"
set "LCD Panel" display text to "Drill : a"

Expected behavior For the first, "My Drill" should be added to the list. For the second, the "LCD Panel" display text should be set to "Drill : a"

jgersti commented 2 years ago
set "LCD Panel" display text to "Drill : a"

The corresponding parse is

  4.1: [Assignment] [AmbiguousString] [BlockType] [Property] [Ignore] *[AmbiguousString]
  4.1: [Assignment] ( *[AmbiguousString] [BlockType] ) [Property] [Ignore] [Selector]
   18: [Assignment] [Selector] [Property] *[Ignore] [Selector]
   20: [Assignment] [Selector] *[Property] [Selector]
 61.1: [Assignment] [Selector] ( [PropertySupplier] *[Selector] )
 61.0: ( [Assignment] *[Selector] [Variable] )
     : [Command]

keeping to as a seperator instead of discarding it as an ignored token (rule 18) would help but would make rule 61.0 (BlockCommandProcessor) in its current form even more complicated

jgersti commented 2 years ago
set myList to []
set myList["thing"] to "My Drill"

line 1 parses fine (but only because to was not discared yet. list assignment is the only case where this behaviour actually matters.)

    1: [Assignment] [AmbiguousString] [Ignore] (*[OpenBracket] [CloseBracket])
  4.3: [Assignment] *[AmbiguousString] [Ignore] [List]
   17: [Assignment] [Variable] [Ignore] *[List]
   18: [Assignment] [Variable] *[Ignore] [ListIndex]
   23: ( *[Assignment] [Variable] ) [ListIndex]
   29: [VariableAssignment] *[ListIndex]
   67: ( *[VariableAssignment] [Variable] )
     : [Command]
    1: [Assignment] [AmbiguousString] ( *[OpenBracket] [AmbiguousString] [CloseBracket] ) [Ignore] [AmbiguousString]
  4.1: [Assignment] [AmbiguousString] [List] [Ignore] *[AmbiguousString]
  4.3: [Assignment] *[AmbiguousString] [List] [Ignore] [Selector]
    7: [Assignment] ( [Variable] *[List] ) [Ignore] [Selector]
   18: [Assignment] [ListIndex] *[Ignore] [Selector]
   29: [Assignment] *[ListIndex] [Selector]
 61.0: ( [Assignment] [Variable] *[Selector] )
     : [Command]

Again rule 61.0 (BlockCommandProcessor) overeagerly consumes tokens to the left. Ideally rule 23 or 63 would be used to match but the parser jumps back to end of the input.

jgersti commented 2 years ago

TL:DR

rule 4.1 needs to have lower priority in the branching since it should only be used for convenience anyway ($ is there for a reason)

making rule 4.1 the last alternative yields:

    1: [Assignment] [AmbiguousString] ( *[OpenBracket] [AmbiguousString] [CloseBracket] ) [Ignore] [AmbiguousString]
  4.3: [Assignment] [AmbiguousString] [List] [Ignore] *[AmbiguousString]
  4.3: [Assignment] *[AmbiguousString] [List] [Ignore] [Variable]
    7: [Assignment] ( [Variable] *[List] ) [Ignore] [Variable]
   18: [Assignment] [ListIndex] *[Ignore] [Variable]
   29: [Assignment] *[ListIndex] [Variable]
   63: ( *[Assignment] [Variable] [Variable] )
     : [Command]
  4.3: [Assignment] [AmbiguousString] [BlockType] [Property] [Ignore] *[AmbiguousString]
  4.3: [Assignment] *[AmbiguousString] [BlockType] [Property] [Ignore] [Variable]
    9: [Assignment] ( *[Variable] [BlockType] ) [Property] [Ignore] [Variable]
   18: [Assignment] [Selector] [Property] *[Ignore] [Variable]
   20: [Assignment] [Selector] *[Property] [Variable]
 61.0: ( [Assignment] *[Selector] [PropertySupplier] [Variable] )
     : [Command]

But this also breaks 2 tests.

edit: sorry for the spam but putting everything into one post was a bit to much

MerlinofMines commented 2 years ago

This was resolved by #234