Git Product home page Git Product logo

atomc-compiler's Introduction

AtomC Compiler

The AtomC Compiler is a work-in-progress compiler that I am building for my Compilation Techniques course. It currently implements some compiler features for the AtomC programming language, a small subset of C.

Features so far

  • Lexical Analyzer: Tokenizes the input source code into a series of tokens.
  • Syntactical Analyzer: Parses tokens to ensure they follow the AtomC language syntax. Absence of output signifies the source file is free of syntactical errors.
  • Domain Analyzer: Checks for domain errors in the source code, such as undeclared variables/functions, or redeclaration of variables.
  • Type Analyzer: Analyzes and verifies the types of variables and expressions to ensure they are used correctly according to the language rules.
  • Stack-Based Virtual Machine: A stack-based virtual machine to execute the generated code. You can test this feature using ./acc --vmtest.
  • Code Generation: Transpiles an AtomC file to virtual machine code and runs it.

Example

Screenshot 2024-03-31 at 14 47 15

Compilation

The compiler can be compiled using make with the following command:

make

Usage

If you don't want to compile it yourself, you can also get the compiler executable for Linux, macOS, and Windows from the releases page.

To compile an AtomC source file, use:

./acc <filename>

To run the stack-based virtual machine test, use:

./acc --vmtest

To test the compiler, you can run the test suite with:

make test

This runs all files in the tests/ directory through the compiler, you can add whatever tests you like in there.

Introduce syntax errors, for example, into tests/testparser.c to see how the compiler responds. If you find that I'm missing an error, or something could be clearer, feel free to raise an issue!

You can do cleanup with:

make clean

atomc-compiler's People

Contributors

stefanfaur avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.