alexschneider / teascript

5 stars 2 forks source link

Parser doesn't support assigning to a variable reference #59

Closed whusted closed 9 years ago

whusted commented 9 years ago

For example:

z[0] = 'hi'

doesn't parse. While I thought this looked simple to account for in the beginning, my esteemed colleague, and the back to back to back MVP of the LMU CS program, @rachelriv, brought up examples of why this is something we all need to think/talk about

whusted commented 9 years ago

A quick thought on what the function might look like (courtesy of the aforementioned @rachelriv):

parseVarRef = ->
  console.log "Parseing Variable Reference"
  exp = parseExp8()

  while ((at ['.', '[']) and
  (next StartTokens.expression))
    if at '.'
      match '.'
      exp = new MemberAccess exp, parseExpression()
    else if at '['
      match '['
      exp = new ListSubscript exp, parseExpression()
      match ']'

  if at([ '++', '--' ])
    op = match()
    exp = new PostUnaryExpression op, exp
  exp
juansc commented 9 years ago

We removed unary increments and decrements when we merged exponents.

rachelriv commented 9 years ago

We've got this working now!