'Need help to code about precedence in Expression

I am trying to make a compiler in c# for c++ language, which will compile and execute c++ code

But problem occurs when i try to assign an expression to a variable example

int a= 1+2*3;

I don't know how can i precedent it.

CFG i am trying to use

E -> E+T | T
T -> T*F | F
F -> number | id | (E)


Solution 1:[1]

If you really need to do this I would recomment to use antlr. You can find a parser and lexer for cpp14 here. With these files you can generate c# code parsing and lexing cpp syntax.

Good luck!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Clemens