Posts tagged Grammar
In Grammar is code we have mentioned that many compiler-compilers reuse the Yacc invention “actions”. And we hinted already that Castle prefers an alternative.
Let’s see why the old concept is outdated … And what is easier to use.
In Compiler Compiler we have seen that we can define a grammar within a Castle-program. And we have argued that each grammars-rule can be considered as a function.
In this post, we look into de details of how this works. And will confirm grammars is code …
In Castle you can define a grammar directly in your code. The compiler will translate them into functions, using the build-in (PEG) compiler-compiler – at least that was it called back in the days of YACC.
How does one use that? And why should you?