chibicc - Simple c compiler return keyword
Add return keyword to simple c compiler
For tokenizer, convert_keywords()
is added to convert kind of token from identity to keyword. So this means that all basic tokens are identity at first and later convert to keywrod type token.
For parser, add extra prudction rule/grammar rule in expr geneartion. stmt = "return" expr ";" | expr-stmt
. New node type ND_RETURN
is added.
For code generation, jmp .L.return
is added to jump to specified assembly code.
For test, add return 1; 2; 3
to test return actually works.
Enjoy Reading This Article?
Here are some more articles you might like to read next: