-
Notifications
You must be signed in to change notification settings - Fork 8
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:
- only generate C code
- only one input and output file
- happy-flow - no compile error checking - assume legal syntax
- no error checking
- compiler has no state - each line holds all the information on how to generate C code from it
- the main function expects to receive exactly 2 arguments
- supported types:
BoolChar-
Int, with no range -
String, with no range, initialized with static range. Supporting constant string ("I am a constant string").
- only stack variables - no global or dynamic, defined with
var [Type] (optional expression),owneris parsed asvar - support
if (expression),else,doandwhile (expression) -
for [var-name] in (expression)will break if[var-name]is equal to(expression), else incrementing[var-name] - not supporting
switchandcase - support functions,
outparameters are generated as pointers, any other access type is ignored (but must exists) - only supports full line comments (
# I am a full line comment) - each blocks must end with one non-indented empty line
- not supporting comment
- no OOP or structs
- only basic file IO support using native C function API implemented in
tl0-file.cc - only basic string support using native C function API implemented in
tl0-string.cc - names and expression are copied to the generated C file as-is, except replacing any
-character with_ - basic assignment support:
var-name := (expression), assignment to a pointed variable is done byout var-name := (expression) -
native type [name]is generated astypedef void* [name] -
native func ...is generated as a function declaration -
#include "tl0-c-api.h"is generated
Suggestions, comments and questions are welcome!
