Skip to content

tonoy30/teeny

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teeny compiler

This is a small compiler to demonstrate how compilers work. It compiles our own dialect to C, while being written in Python.

It supports:

  • Numerical variables
  • Basic arithmetic
  • If statements
  • While loops
  • Print text and numbers
  • Input numbers
  • Labels and goto
  • Comments
# Compute average of given values.

LET a = 0
WHILE a < 1 REPEAT
    PRINT "Enter number of scores: "
    INPUT a
ENDWHILE

LET b = 0
LET s = 0
PRINT "Enter one value at a time: "
WHILE b < a REPEAT
    INPUT c
    LET s = s + c
    LET b = b + 1
ENDWHILE

PRINT "Average: "
PRINT s / a

About

This is a small compiler to demonstrate how compilers work. It compiles our own dialect to C, while being written in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published