How to evaluate a DSL with PARSE in Rebol? -
as learnt dsl, realized parse dialect in rebol can great lexer , parser. there example the parse tutorial:
    expr:    [term ["+" | "-"] expr | term]     term:    [factor ["*" | "/"] term | factor]     factor:  [primary "**" factor | primary]     primary: [some digit | "(" expr ")"]     digit:   charset "0123456789"      probe parse "4/5+3**2-(5*6+1)" expr     ;will output true   the code above verifies if expression conforms "grammar" defined above. question is:
- how compute or evaluate it?
 - how denote prior of operators such "*" , "+"?
 
1, generate either string or better block e.g. collect, can evaluate do.
 2, there old example dialect gabriele santilli on rebol.org operator precedence.
Comments
Post a Comment