INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression parser questions  (Read 1535 times)

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Expression parser questions
« on: July 28, 2011, 04:29:21 pm »

Question: How is MC doing its expression parsing for the expression language?

Is there formal grammar, or stack based state machine, or ...?
Logged
The opinions I express represent my own folly.

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41941
  • Shoes gone again!
Re: Expression parser questions
« Reply #1 on: July 28, 2011, 04:31:29 pm »

I'm not certain what you're asking, but the expression parser is stack based.

This allows it to nicely handle nested expressions and parenthesis.

Evaluation of expressions runs the stack in an interpretive manner.  In other words, the stack is not compiled to machine code.
Logged
Matt Ashland, JRiver Media Center

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression parser questions
« Reply #2 on: July 28, 2011, 05:15:32 pm »

I was wondering if you had a formal grammar defined, and then used software to build your lexer/parser.

But it sounds like you've built your own.

I've been mucking about with an expression parser that would do essentially something like this:

http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html  [enable javascript to use]

But I also thought about writing a formal grammar and using one of the many lexer/parser builders available.

Once an expression gets beyond a couple of nested IF statements, it becomes too cumbersome.  Finding a missing paren, or comma, can be very challenging:

http://yabb.jriver.com/interact/index.php?topic=65519.new;topicseen#new

It would be ideal if MC could do some basic structured presentation of an expression for both entry and viewing (but I know you folks are busy).
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up