3 ms·
You could use https://en.wikipedia.org/wiki/Yacc https://en.wikipedia.org/wiki/Yacc I decided to write my own lexer/parser/compiler it's pretty straightforward
by r1chardnl 5y ago
You could use https://en.wikipedia.org/wiki/Yacc https://en.wikipedia.org/wiki/Yacc
I decided to write my own lexer/parser/compiler it's pretty straightforward.
Sources I use(d) to program this, e.g look at resulting assembly from other compilers or look at how the AST is generated for other languages.
https://en.wikipedia.org/wiki/Recursive_descent_parser https://en.wikipedia.org/wiki/Recursive_descent_parser
https://en.cppreference.com/w/c/language/operator_precedence https://en.cppreference.com/w/c/language/operator_precedence
https://godbolt.org/ https://godbolt.org/
https://astexplorer.net/ https://astexplorer.net/
I didn't start writing C yesterday, and most of the things are just stuff I've learned over the years and seeing how other languages work and then just use what I know to try to program in a logical manner.
Also I've written a implementation of a scripting language (compiler and VM) before in similar fashion.
https://github.com/riicchhaarrd/gsc https://github.com/riicchhaarrd/gsc