Skip to content

Lightweight, fast, modern and scripting language

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

thmxv/tx-lang-cxx

Repository files navigation

The Tx programming language

About Tx

Tx aims to be oriented towards safety, speed, power and minimalism.

Tx is inspired by Lua. The code and implementation is based on the book Crafting Interpreters by Robert Nystrom. The syntax and feature set are inspired by languages such as Python, Rust, Wren and Swift among others.

The code is written, as much as possible, in modern C++. Trying to be almost completely constexpr.

Disclaimer

Tx is still very much a work in progress.

Documentation

Backlog

  • Do not allow forward decl 2x the same var
  • Allow return as last statement of block that does not return nil
  • Replace gsl Expect macro to something less likely to collide
  • Maybe add option to error_token to mark the end of the token or the start in error message hint
  • Tests for all the error_token() code paths
  • Multi-line entry in REPL
  • Fix error in REPL in entry that follows an error
  • Support expression result in REPL
  • Reserve keywords pub, with, type, Type, abstract, override, final
  • Better float formatting: 1.0e20 instead of 1.e20. Test print/parse loop
  • Check arity/signature of native fn
  • Fix TODOs in the code
  • Replace runtime errors by compile time (keep runtime error in degug)
  • Go over all the tests one more time (Some do not make much sense for tx and some others do not test all code paths)

To consider

  • Sync GC and allocator, meaning the GC is always triggered before the pool allocator falls-back to the upstream allocator.
  • Chapter 25 challenges
  • Chapter 26 challenges
  • Allow "var a = a;" in the case of shadowing and not assigning to self
  • Option to set maximum recursion level, starting stack and frame array size, and minimum memory consumption (do not round to next power of 2)
  • Optimize instruction_prt access (chapter 24 challenge) + benchmark
  • Allow function overload with diff arities (if possible)
  • Universal Function Call (UFC)
  • Add OP CODES for common constant values (0,1,2,-1,"")
  • Clean up utf8 conv, utf8 lenght, resize once
  • Loop/block labels with support in break and continue
  • Allow to use break to break out of a block (using labels only)
  • Better const correctness for container elements
  • Use char8_t and u8string_view (needs libfmt support)

Roadmap

v0.1.0

  • Bytecode array
  • Interpret bytecode
  • Scanning tokens
  • Parsing/compiling expressions
  • Value types
  • String
  • Hash table
  • Global variables
  • Local variables
  • Jumping
  • Functions and call
  • Tests
  • Closure
  • Garbage collection
  • Backlog/FIXMEs/TODOs
  • CI, coverage, fuzzing, ...

v0.2.0

  • Type checking
  • Documentation

v0.3.0

  • Struct and instances
  • Methods and initializer
  • Traits
  • Inheritance?
  • String concatenation
  • String interpolation
  • Array and Map values (generic types)
  • Tuples (need variadic generic types)
  • Range based for loop
  • Pattern matching
  • Documentation

v0.4.0

  • Modules
  • Optimizations
  • Documentation

Minimum target for realease candidate

  • Final syntax/grammar
  • Reserve all future keywords
  • Benchmarks
  • Editors support (LSP)
  • Modules for core and std
  • Type alias
  • Recursive types
  • Documentation

Later 1.0 versions

  • Syntax highlighting and completion in REPL
  • Fibers
  • Threads
  • Async and await
  • Add 'with' statement
  • Package/dependency manager
  • Tools (debugger, ...)
  • Virtual env

v2.0.0

  • Refactor instruction set/Switch to register based VM
  • Better GC

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.