How amansingh-13/cs316-sclp-compiler works
Main Components
• Compiler Frontend:
• Lexical Analyzer: Represented by lexer.l files (found in A1, A2, A3, A4, A5, and within group7 directories). This module scans source code and converts the input into tokens.
• Parser: Based on parser.y in several group7 directories, this component takes tokens from the lexer and builds a parse tree.
• AST (Abstract Syntax Tree) Builder: The ast.hpp files and possibly tac.hpp (in A5) illustrate where the AST is defined and subsequently processed.
• Semantic Analyzer: Items like semantics.hpp (present in A2, A3, A4, A5/group7) indicate the semantic checking phase.
• Compiler Backend (if applicable):
• There are hints (e.g., “sm.cpp” in A3 and additional “tac.hpp” in A5) that further phases such as intermediate code generation or transformation are incorporated.
• Test & Resource Management:
• Resources are organized in “*-Resources” directories for each assignment (A1, A2, etc.), which include test cases (separated into levels) and reference implementations (L1-sclp to L4-sclp).
• Example programs and their corresponding tokens, input files, etc., serve as the input test corpus for verifying the compiler’s functionality.
• Build & Configuration:
• Makefiles at the top level in A1 and within the group7 directories indicate how the different components are compiled and linked.
• From the AST node creation, link to the Semantic Analyzer which verifies correctness and performs type checking.
• A separate “Testing Framework” component (or “Test Case Repository”) that interacts with the compiler core by feeding sample test cases (from the resource directories) into the overall pipeline.
• The Makefiles and configuration files can be represented as the “Build/Integration” layer that assembles all these components.
Architectural Patterns and Design Principles
• Modularity: Each phase (lexing, parsing, semantic analysis, etc.) is encapsulated in its own module across the project structure.
• Incremental Development: The progression from A1 through A5 (and similarly the levels of test cases) suggest that the compiler was built in incremental phases—each assignment extending or refining previous functionality.
• Reusability and Extensibility: Separate implementations in “reference-implementations” and “group7” suggest that the design is meant to be compared, extended, or benchmarked.
Relevant Technologies and Frameworks
• Lex & YACC: With lexer.l and parser.y present, clearly indicate the use of classic compiler generators.
• C/C++: The files (e.g., *.c, *.cpp, *.hpp) point to C-family languages.
Elements
• External resources like the online info at https://www.cse.iitb.ac.in/~uday/sclp-web/ which might provide additional context.
Final Touches
• That each assignment (A1 up to A5) might have slight variations in implementation and could be represented as “modules” or “layers” built atop a common core.