chibicc - Simple c compiler return keyword

Add return keyword to simple c compiler

Commit history

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:

  • Learning-based memory allocation for C++ server workloads summary
  • my question:
  • Binary search algorithm variant
  • Docker Rocksdb build
  • Difference between Dockerfile and Docker Compose