Skip to content

eklimo/cygnus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cygnus

Cygnus is an in-progress compiler for a hypothetical programming language inspired by Swift and Rust. Although the eventual goal is compilation to machine code, only its front-end is currently complete, meaning that it is capable of fully analyzing input programs and discarding invalid inputs.

Compiler features

  • Lexer - breaks up input program into series of tokens that have individual meaning
    • Flexible keyword/operator/separator specification including any ASCII characters
  • Parser - constructs abstract syntax tree that represents the structure of the program
    • Top-down Pratt/recursive descent style
    • Able to assign arbitrary precedence to any operator in the language
  • Symbol resolution - determines which symbol in the program every identifier refers to
  • Type checker - verifies correct operations between types in the program
  • Detailed and visual error reporting, in the style of the Rust compiler

Language features

  • Standard arithmetic and logical operators
  • Statements and blocks
  • Variable definitions
  • Function definitions and calls
  • if expressions
  • while expressions

Demo

For further information on what Cygnus is capable of, see the examples in the demo directory, or download this project and try your own programs!

Usage

After building, execute cygnus with the path to a .cy file, or add --help for more information on CLI options. Optionally, add --debug to see the compiler's debug output.

e.g.

$ cygnus "test/lang/fizzbuzz.cy" --debug

Building

Dependencies

  • C++17-compatible compiler
  • CMake 3.1+

Linux

$ git clone https://github.com/eklimo/cygnus.git && cd cygnus
Cloning into 'cygnus'...

$ mkdir build && cd build

$ cmake .. && make
...
[100%] Built target cygnus

The executable cygnus will be located in build/bin.

Technologies

  • C++17
  • Python

About

Cygnus compiler

Resources

License

Stars

Watchers

Forks

Languages