Tokyo Night Theme (Dark & Light Modes)
- β Features
- πΈ Screenshots
- ποΈ Technical Implementation
- βοΈ Technologies
- π Getting Started
- π§ͺ Testing
- π License
- π₯ Authors
A modular conditional command parsing utility with semantic analysis:
-
β Advanced Parsing Engine
- Implements a Recursive Descent Parser to handle conditional commands, assignments, and expressions with clear grammar structure.
-
π Custom Lexer & Grammar Analysis
- Robust Lexer for tokenization and type recognition (supporting
float,string,char, andint). - First and Follow set calculations to support predictive parsing and error handling.
- Supports comments in the input:
// line comments/* block comments */
- Robust Lexer for tokenization and type recognition (supporting
-
π§ Semantic Analysis
- Enforces semantic rules such as type consistency in assignments and expressions.
- Symbol table management for identifier tracking and type binding.
-
π¨ Syntax Tree Visualization
- TreePrinter utility provides a clear, labeled printout of the abstract syntax tree (AST), including node types and relationships.
-
π₯οΈ Modern Web Interface
- Web controller (ParserController) and a responsive
index.htmlinterface styled with Tailwind CSS. - Includes light/dark themes inspired by the TokyoNight palette and a toggle switch for user preference.
- Web controller (ParserController) and a responsive
-
π§ͺ Test-Driven Development
- Extensive unit tests for Lexer, ParserService, Semantic Analysis, and FirstFollowCalculator ensure correctness and robustness.
Visual output from TreePrinter displaying the parsed conditional command tree
The parser is built using the following context-free grammar:
S β if ( E ) S else S | id = E
E β E + T | E - T | T
T β T * F | T / F | F
F β ( E ) | id
Note: In this grammar:
idrepresents either an identifier (e.g., variable names) or a literal of supported types:float,string,char, orintif,else, and operators (+,-,*,/) are terminal symbols
src/
βββ main
β βββ java/br/edu/fesa/Conditional_Command_Parser
β β βββ ConditionalCommandParserApplication.java # Main Spring Boot entry point
β β βββ exception
β β β βββ LexicalException.java # Custom lexical error handling
β β β βββ SemanticException.java # Custom semantic error handling
β β β βββ SyntaxException.java # Custom syntax error handling
β β βββ controller
β β β βββ ParserController.java # REST API endpoint handler
β β βββ model
β β β βββ Assignment.java # 'id = E' assignment nodes
β β β βββ BinOp.java # Binary operations (+,-,*,/)
β β β βββ CharLiteral.java # Char literal node
β β β βββ FloatLiteral.java # Float literal node
β β β βββ Identifier.java # ID nodes (variables/numbers)
β β β βββ IfStatement.java # If-else control structures
β β β βββ NumberLiteral.java # Numeric literal node
β β β βββ ParserResponse.java # API response wrapper
β β β βββ StringLiteral.java # String literal node
β β β βββ SyntaxNode.java # Base AST interface
β β β βββ Token.java # Token type/value storage
β β βββ semantic
β β β βββ Symbol.java # Symbol representation for semantic analysis
β β β βββ SymbolTable.java # Symbol table for variable scope management
β β βββ service
β β β βββ ParserService.java # Core parsing logic orchestration
β β βββ utils
β β βββ FirstFollowCalculator.java # Grammar analysis utilities
β β βββ Lexer.java # Source code tokenization
β β βββ RecursiveDescentParser.java # Syntax tree construction
β β βββ SemanticAnalyzer.java # Semantic analysis for type checking
β β βββ TreePrinter.java # AST visualization generator
β βββ resources
β βββ application.properties # Spring configuration
β βββ static
β β βββ styles.css # TokyoNight theme styling
β βββ templates
β βββ index.html # Web interface template
βββ test
βββ java/br/edu/fesa/Conditional_Command_Parser
βββ ConditionalCommandParserApplicationTests.java
βββ service
β βββ ParserServiceTest.java # Service layer tests (7 tests)
βββ utils
β βββ FirstFollowCalculatorTest.java # Grammar analysis tests (2 tests)
β βββ LexerTest.java # Tokenization tests (18 tests)
β βββ RecursiveDescentParserTest.java # Recursive descent parser tests (14 tests)
β βββ SemanticAnalyzerTest.java # Semantic analysis tests (6 tests)- Backend: Spring Boot 3.4.4 + Java 17
- Frontend: Thymeleaf + Tailwind CSS
- Parsing Techniques: Recursive descent parsing, custom lexer/tokenization, first/follow calculations
- Build: Maven 3.9+
- Testing: JUnit 5 (47 Total Tests)
- Java Development Kit (JDK) 17
- Maven 3.9+
Clone the repository and build the project:
git clone git@github.com:Rutpiv/Conditional-Command-Parser.git
cd Conditional-Command-Parser
mvn clean installStart the application:
mvn spring-boot:runAccess the web interface at: π http://localhost:8080
Comprehensive validation coverage:
mvn test- β ParserService: 7 tests ensuring correct parsing logic
- β FirstFollowCalculator: 2 tests validating grammar analysis
- β Lexer: 18 tests verifying tokenization accuracy
- β RecursiveDescentParser: 14 tests for syntax tree generation
- β SemanticAnalyzer: 6 tests validating type checking and symbol management
Distributed under the BSD 3-Clause License.
Students from Engenheiro Salvador Arena College: β‘οΈ Complete Contributors List
Compilers Course Project β’ 2025 Semester