Language parsing

Parsing and transpiling

Concepts

Long switch in a loop, can be used for state machine, but it's not adviced to use long switch for parsing, because it's often need multiple states (to restore previous ones). Use recursive descent parserarrow-up-right instead.

Generators

Parser examples

Tokenizer + parser

Use gotos, "This is called computed (or assigned) goto and is a GCC extension"

  • https://github.com/quartzjer/js0n/blob/master/src/js0n.c

  • https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

  • https://news.ycombinator.com/item?id=4387156

Syntax exemples:

Syntax formats

Railroad diagram

Last updated