Skip to content

evaluating expressions ~ grammar precedence #32

Closed as not planned
Closed as not planned

Description

@kapilt

i was trying to see if i could evaluate an expression to fold constants ie.

given
count = true && true ? 1 : 0
get to
count = 1

overriding dict transformer shows some issues on precedence in the grammar. ie use of conditional shows that its being evaluated early before binary terms, ie. per extant grammar precedence is
true && (true ? 1: 0)
instead of
(true && true) ? 1 : 0

printing the parse tree exemplifies, ie parsing this source test {count = true && true ? 1 : 0} with the grammar results in this parse tree

start
  body
    one_line_block
      identifier        test
      identifier        count
      binary_op
        expr_term
          true_lit
        binary_term
          binary_operator       &&
          conditional
            expr_term
              true_lit
            expr_term
              int_lit   1
            expr_term
              int_lit   0
      new_line_or_comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions