Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adl rules have no operator precedence #4

Open
pieterbos opened this issue Oct 16, 2015 · 4 comments
Open

adl rules have no operator precedence #4

pieterbos opened this issue Oct 16, 2015 · 4 comments
Assignees

Comments

@pieterbos
Copy link
Contributor

The operators in the rules section have no operator precedence. It's very useful to include this in the antlr grammar. Something along the lines of:

expr:  mult ('+' mult)* ;
mult:  atom ('*' atom)* ;
atom:  INT | '(' expr ')' ;

You can then simply walk the tree to evaluate expressions.

Useful both for arithmetic and boolean expressions.

@wolandscat
Copy link
Member

The parsing order of precedence should be correct now.

@wolandscat wolandscat self-assigned this Oct 21, 2015
@pieterbos
Copy link
Contributor Author

Your fix for the parsing of operator precedence does not yet work. I fixed it in Archie.

See the branch rule_evaluation of archie at https://github.com/nedap/archie/tree/rule_evaluation. I fixed operator precedence both for boolean and arithmetic expressions, with soms tests. I also implemented expression variables declarations in both the grammar and evaluation. I'll create a pull request for the grammar as soon as i have more of the grammar implemented, working and tested.

Also, the ADL language spec is missing the modulo operator. The AOM spec does list it.

@pieterbos
Copy link
Contributor Author

For the latest rule grammar in archie, see the grammar in the master-branch of archie.

That does not yet parse function calls and it has some simple changes to the language to fix some rather hard to fix ambiguity i mentioned on the mailing list. I'll respond to that mail soon :)

@wolandscat
Copy link
Member

My view on this at the moment is that its' better to wait until you get a (reasonably) complete working 'rules' section grammar that corresponds to the Expressions Language spec (where the latter might need some tweaks as well), and then when those two are in sync, I'll replace the current adl_rules.g4 with what you have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants