Skip to content

jqcorreia/zero

Repository files navigation

Zero Lang

Procedural language with basics done right. Straightforward, correct and if possible with some syntatic sugar on top. Aims to be explicit but to not sacrifice all the creature comforts of a modern language.

Already done:

  • Lexing
  • Parsing / AST construction (straightforward Pratt parser)
  • Basic Checker (semantic and basic types)
  • Order-independent declarations
  • Integers and Boolean support
  • Float support (f16, f32, f64)
  • C-String support
  • Comments (surprisingly hard to implement well actually)
  • User functions
  • Recursion
  • Structs (including nested structs)
  • Arrays (declarations, literals, indexed read/write, nested in structs, compile-time bounds check)
  • Unconditional For loop with break and continue
  • Single file, single module
  • External function interface
  • Global scope import (a la #include)
  • Pointers (address-of, derefence and dereference-assign)

Right now this is an LLVM project and it will be for a while. Trying not to tangle the code to much to that. Potentially this README can look a lot different in a couple of months if this becomes a serious project.

TODO

  • Do not need forward declaration with symbol table pass and LLVM function declaration
  • Basic type system
  • Basic External functions system and cleanup the printf mess
  • Implement a really dumb variadic marker
  • User defined types (i.e structs)
  • Global scope import mechanism
  • Struct field accessor
  • Implement support for arbitrary "_" character in numbers (e.g for thousands separator)
  • Check types for function calls
  • Implement float support
  • Arrays with compile-time bound checked access
  • Pointer types (address-of, dereference)
  • Enums
  • Tagged Unions
  • Make sure that the available types are synched with the primitive types in codegen
  • For-in-range loops (exclusive .. and inclusive ..=)
  • Proper string with bound check and not null-terminated
  • Make external blocks its own AST node kind, in order to have linking rules and prefixes
  • Make sure that lexer is UTF-8 compliant
  • Have the notion of addressable types (?)
  • Add check for cyclic import
  • Runtime bounds checking for array access
  • API and code cleanups after a first working pass

Try it

odin build .
./zero run tests/basic.z 

Testing

All the compiler tests reside in tests/ and adding a file there will automatically add it to the test suite Run the tests by simply calling odin test .

Dependencies

  • linux at least until we properly know what we are doing
  • cc as the C compiler that does the linking in the end
  • raylib in order to run the raylib example in tests/raylib.z

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages