Skip to content

TL0 Features

Meir Cohen edited this page Mar 14, 2018 · 1 revision

As the initial step, TL0 supports the minimum needed for a working compiler:

  1. only generate C code
  2. only one input and output file
  3. happy-flow - no compile error checking - assume legal syntax
  4. no error checking
  5. compiler has no state - each line holds all the information on how to generate C code from it
  6. the main function expects to receive exactly 2 arguments
  7. supported types:
  • Bool
  • Char
  • Int, with no range
  • String, with no range, initialized with static range. Supporting constant string ("I am a constant string").
  1. only stack variables - no global or dynamic, defined with var [Type] (optional expression), owner is parsed as var
  2. support if (expression), else, do and while (expression)
  3. for [var-name] in (expression) will break if [var-name] is equal to (expression), else incrementing [var-name]
  4. not supporting switch and case
  5. support functions, out parameters are generated as pointers, any other access type is ignored (but must exists)
  6. only supports full line comments (# I am a full line comment)
  7. each blocks must end with one non-indented empty line
  8. not supporting comment
  9. no OOP or structs
  10. only basic file IO support using native C function API implemented in tl0-file.cc
  11. only basic string support using native C function API implemented in tl0-string.cc
  12. names and expression are copied to the generated C file as-is, except replacing any - character with _
  13. basic assignment support: var-name := (expression), assignment to a pointed variable is done by out var-name := (expression)
  14. native type [name] is generated as typedef void* [name]
  15. native func ... is generated as a function declaration
  16. #include "tl0-c-api.h" is generated

Clone this wiki locally