Skip to content

kelsiodev/cspp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cs++ — Mini C# Compiler in C++

Language: C++17 Build Status Platform License: Educational

🧠 An experimental compiler built in C++17 implementing the full analysis chain: lexical, syntactic, and semantic, inspired by the C# language. This project showcases compiler construction knowledge with modern software engineering practices.

📌 Features

  • Tokenization for .cs source files
  • Recursive descent parser with modular AST
  • Semantic analysis via Visitor Pattern
  • Modular architecture with lexer, parser, and analyzer separation
  • JFLAP integration for DFA visualization

🧠 Sample Code (samples/hello.cs)

using System;

class Program{
	// exemplo de comentário
	static void Main(string[] args){
		Console.WriteLine("Hello, World!");
	}
}

🛠️ Requirements

Tool Minimum Version
g++ 7.0+ with C++17 support
make Any
java 8+ (for JFLAP only)

🚀 Build & Run

🔧 Build

make

Binary: bin/cs++

▶️ Run

make run

Runs samples/hello.cs.

🧹 Clean

make clean

🗂️ Project Structure

.
├── docs/               # Documentation and grammar specs
├── include/            # C++ headers (lexer, parser, analyzer)
├── src/                # C++ implementations
├── samples/            # `.cs` test files
├── tools/jflap/        # JFLAP DFA visual tool
├── jflap/              # DFA diagrams (.jff, .png)
├── makefile
└── readme.md

🧰 Tools

📥 Launch JFLAP

make jflap
# or manually:
java -jar tools/jflap/jflap.jar

📚 Documentation

Available in docs/:

  • cspp.pptx, cspp.docx
  • grammar/ with BNF, regex, C# Microsoft grammar, and syntactic grammar

🔍 Technical Overview

Lexer

  • Implements DFA manually (src/lexer.cpp)
  • Token definitions in token.h
  • Verified with JFLAP

Parser

  • Recursive descent parser (src/parser.cpp)
  • AST modules: node, expression, statement

Analyzer

  • Visitor pattern-based semantic analysis (src/analyzer.cpp)
  • Validates types, scopes, and declarations

📄 License

Developed for educational purposes for the Compilers course.

👨‍💻 Author

Kélsio Mateus
Purpose-led software engineer passionate about compilers

📌 References

"A compiler is the engineer of the bridge between logic and machine." — ✨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published