Skip to content

NatA Lang is an educational language and compiler built in C to explore reader, scanner, and parser stages using formal models like REs and BNF.

Notifications You must be signed in to change notification settings

ThisIsAntonio/Compilers_NatA_Lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  NatA Lang โ€“ Educational Compiler Front-End in C

๐ŸŒŸ Overview

NatA Lang is a domain-specific programming language and educational compiler developed as part of the CST8152 - Compilers course at Algonquin College (Fall 2023). Created by Marcos Antonio Astudillo Carrasco and David Burchat, this language project is structured to explore the stages of compiler construction:

  • ๐Ÿงพ Reader (Buffer) โ€“ Handles file input and buffering
  • ๐Ÿงช Scanner (Lexical Analyzer) โ€“ Tokenizes source code into meaningful elements
  • ๐Ÿ“ Parser (Syntax Analyzer) โ€“ Validates structure using BNF-defined grammar

๐Ÿ’ก Language Features

Inspired by Go and C-style languages, NatA emphasizes simplicity and educational clarity. Supported constructs include:

  • ๐Ÿ“ฆ Variable declarations with types (int, float64, string, byte)
  • ๐Ÿ”„ Control structures: if, else, for, while
  • ๐Ÿงฎ Arithmetic and logical operations
  • ๐Ÿ“ค Output and ๐Ÿ“ฅ input commands
  • ๐Ÿงฉ Functions with parameter and return type support

๐Ÿ—‚๏ธ Project Structure

NatA_Lang/
โ”‚
โ”œโ”€โ”€ input/                  # Sample .nat files for testing
โ”œโ”€โ”€ Compilers.c/h          # Shared definitions
โ”œโ”€โ”€ Reader.c/h             # Reader logic
โ”œโ”€โ”€ MainReader.c           # Reader test main
โ”œโ”€โ”€ Scanner.c/h            # Scanner logic (lexical analyzer)
โ”œโ”€โ”€ MainScanner.c          # Scanner test main
โ”œโ”€โ”€ Parser.c/h             # Parser logic (syntax analyzer)
โ”œโ”€โ”€ MainParser.c           # Parser test main
โ”œโ”€โ”€ Runner.bat             # Batch script for compilation/execution
โ”œโ”€โ”€ CMakeLists.txt         # CMake configuration
โ””โ”€โ”€ CMakePresets.json      # CMake environment presets

โš™๏ธ Building and Running

๐Ÿ”ง Requirements

  • ๐Ÿ–ฅ๏ธ C Compiler (GCC or MSVC)
  • ๐Ÿ› ๏ธ CMake โ‰ฅ 3.20
  • ๐ŸชŸ Windows (preferred) or any POSIX-compliant OS

๐Ÿ”จ Build Instructions

cd /path/to/NatA_Lang
cmake -S . -B build
cmake --build build

๐Ÿš€ Run Instructions

  1. Place .nat files in build/ directory
  2. Run Runner.bat or manually run the compiled executable
  3. Check output .out and error .err files in the same directory

๐Ÿงช Sample Programs

Available in input/:

  • INPUT0_Empty.nat โ€“ Verifies compiler response to an empty file
  • INPUT1_Hello.nat โ€“ Simple "Hello, World!" output
  • INPUT2_Volume.nat โ€“ Calculates sphere volume using expressions
  • INPUT3_Factorial.nat โ€“ Demonstrates recursion and loops
  • INPUT4_Datatypes.nat โ€“ Validates variable declarations
  • INPUT5_Big.nat โ€“ Comprehensive stress test of compiler capabilities

๐Ÿ“† Project Milestones & Version History

โœ… A11 โ€“ Language Proposal

a11-language-proposal โ€“ ๐Ÿ“… Sep 23, 2023
Initial language specification, keywords, syntax rules, datatypes, and test cases.

โœ… A12 โ€“ Reader (Buffer)

a12-reader-buffer โ€“ ๐Ÿ“… Oct 8, 2023
Dynamic memory reader system built to handle secure and efficient file reading.

โœ… A21 โ€“ Lexical Analysis Model

a21-language-model โ€“ ๐Ÿ“… Oct 22, 2023
Defined REs, token classes, automata diagrams, and transition tables.

โœ… A22 โ€“ Scanner (Lexer)

a22-scanner โ€“ ๐Ÿ“… Nov 12, 2023
Tokenizer for source code, generating token streams and error outputs.

โœ… A31 โ€“ Grammar Specification

a31-bnf-grammar โ€“ ๐Ÿ“… Nov 26, 2023
Created BNF rules for the language to support recursive-descent parsing.

โœ… A32 โ€“ Parser Implementation

a32-parser โ€“ ๐Ÿ“… Dec 10, 2023
Parser validates syntax and handles structural errors.


๐Ÿ‘ฅ Contributors

  • Marcos Antonio Astudillo Carrasco โ€“ Lead Developer
  • David Burchat โ€“ Co-Developer

๐Ÿงพ License

This project is for academic and educational use. No open-source license applies.


๐Ÿ“ซ Connect With Me

๐ŸŒ Portfolio ๐Ÿ’ผ LinkedIn ๐Ÿฑ GitHub

Email: m.astudillo1986@gmail.com

About

NatA Lang is an educational language and compiler built in C to explore reader, scanner, and parser stages using formal models like REs and BNF.

Topics

Resources

Stars

Watchers

Forks