Max Base

Results 266 comments of Max Base

I checked its parser. They did not divide the phrase into several groups. And he manages these using BISON. https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1041 Since we are writing Parser by hand, we need to...

Dear @snapogod; https://github.com/One-Language/One/issues/71#issuecomment-854995262 Can you help us complete the BNF grammar? https://github.com/One-Language/One/blob/master/grammar.BNF We need to know grammar of all operators.

Another nice implementation of the expression parser. But it does not help us much. https://github.com/maxicombina/c-calculator/blob/master/calculator.c#L170 ```c int get_op_precedence(char op) { int res = 0; if (op == '+' || op...

Some useful references I find yesterday: https://depositonce.tu-berlin.de/bitstream/11303/2630/1/Dokument_46.pdf https://cdn2.hubspot.net/hubfs/3881487/ExprParser_User_Guide.pdf?t=1517563829446

Another nice implementation of the expression parser: https://github.com/programoworm/Expression_Recogniser/blob/master/expression.c This is something I extracted from the above code but it is still incomplete and has a problem: ``` parseFactor = "+"...

I found some online tools that can test grammar. This is very interesting and it is better to test the grammars in the same way. - https://mdkrajnak.github.io/ebnftest/ - https://bnfplayground.pauliankline.com/ More...

Another nice example from `PEG.JS`: ``` // Simple Arithmetics Grammar // ========================== // // Accepts expressions like "2 * (3 + 4)" and computes their value. Expression = head:Term tail:(_...

The above codes are summarized as follows: ``` Expression = Term ( ("+" / "-") Term)* | Term Term = Factor ( ("*" / "/") Factor)* Factor = "(" Expression...

A tiny YACC/Bison example: ``` exp: exp OPERATOR_PLUS exp | exp OPERATOR_MINUS exp | exp OPERATOR_MULT exp | exp OPERATOR_DIV exp | LPAREN exp RPAREN | NUMBER ``` https://www.cs.uic.edu/~spopuri/ibison.html

Okay, so again we need "Precedence of operators in BNF grammar" with all operators not only + - * /.