Project Type A: Complete SPL Compiler with Executable BASIC Code Generation
- Maximum Points: 10/10
- Status: COMPLETE ✅
This is a Project Type A submission that implements a complete SPL (Students' Programming Language) compiler with all required phases:
✅ Lexical Analysis - Tokenizes SPL source code
✅ Syntax Analysis - Parses SPL grammar and builds AST
✅ Semantic Analysis - Variable/function naming and scope validation
✅ Type Checking - Type compatibility verification
✅ Code Generation - Generates executable BASIC code
./compile.sh
cd tests
java SPLInterface <input_file.txt>- SPL Program in a
*.txtfile
- "Tokens accepted" - if lexical analysis succeeds
- "Syntax accepted" - if parsing succeeds
- "Variable Naming and Function Naming accepted" - if semantic analysis succeeds
- "Types accepted" - if type checking succeeds
- Executable BASIC code - Generated as
*_output.txtfile
- "Lexical error:" + details for tokenization issues
- "Syntax error:" + details for parsing issues
- "Naming error:" + details for scope violations
- "Type error:" + details for type mismatches
- ✅ Global variables (
glob { x y }) - ✅ Procedures with parameters (
proc { test(a) { ... } }) - ✅ Functions with return values (
func { add(x y) { ... return result } }) - ✅ Local variables with proper scoping (
local { var }) - ✅ Control flow (while loops, if-else branches)
- ✅ Expressions (arithmetic, logical, comparison operations)
- ✅ Print statements and variable assignments
- ✅ Function calls in assignments (
x = add(a, b)) - ✅ Procedure calls (
test(parameter)) - ✅ Nested expressions (
(x plus y) mult z) - ✅ Complex control structures with functions/procedures
Modern BASIC/FreeBASIC compatible code generation with:
SUBandFUNCTIONdefinitionsDIMvariable declarationsWHILE/WENDloop structuresEXIT SUB/EXIT FUNCTIONfor early terminationPRINTstatements for output
This SPL compiler successfully achieves Project Type A specifications:
- Complete front-end compilation pipeline
- Full semantic analysis with scoping and type checking
- Executable BASIC code generation
- Comprehensive error reporting at every phase
- Support for the complete SPL grammar specification