Open ppdog0 opened 3 years ago
So, I would like to write this:
unary → ( "!" | "-" )* primary ;
Yes, that works fine too. I used a recursive grammar rule in the book because that mirrors the recursive code we write to parse it, but an iterative grammar rule is also fine (and you can parse it iteratively too if you want).
Before I would like express my thanks to you since we have compiler principles this semester. Our compiler project is totally based on your work and we change the code by ourselves so it can scan C-style code. When we finish it , I would like to share it there.
Now I am working on grammar analysis. In the parsing-expression part, the book says:
which is different from other grammar. For example, for term we have
In this grammar, we use '*' to make it iteration-style. However, we can see that Unary is like recursion-style.
So, I would like to write this:
to make it recursive, we write
that's all, and I would like to share my recursion-style grammar there: