Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lua interpreter in Python

This is my second take on writing a Lua-To-Python compiler, it includes:

  • Lexer
  • Parser
  • A internal AST representation
  • Repl
  • Interpeter

Running repl

  • python repl.py

TODO

  • Introduce ; as a separator
  • Named functions
  • Not defined variables should return nil
  • Modulo operator
  • and operator
  • or operator
  • elseif statement
  • Variables with numbers in name
  • Iterator for Table using pairs/ipairs
  • _G for globals access
  • for loop
  • while loop
  • repeat loop
  • Short circuit / tenary operator
  • Dot property syntax in Table for string keys
  • Numbers beginning with . (Ex .5)
  • Handle global vs local variables in lua style
  • Function calls with single params should not require parens
  • Metatable support for tables

Supports

  • Single and multiline comments
  • Variable assignments
  • Numbers
  • Strings
  • Tables
  • Addition, multiplication and division
  • If statements
  • Comparison operators (==, >=, >, <, <≠, ~=)
  • String concat ..
  • return
  • function declarations (both named and anymous with closures)
  • not logical operator
  • Negative values
  • Table indexing
  • Table count with #
  • Non existing identifiers return nil
  • Modulo operator

References

About

A Lua interpreter written in python.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages