How keshavig/matek works
Main Components
• Lexer: Represented by lexer.cpp/lexer.h that converts input characters into tokens.
• Parser: Indicated by parser.cpp/parser.h, responsible for syntax analysis and building an Abstract Syntax Tree (AST).
• Operator Handling: Shown in operators.cpp/operators.h, this part handles operator definitions and evaluations.
• AST / Node Representation: node.h defines the data structures likely forming the nodes of the AST.
• Checks and Validations: Checks.cpp/checks.h might be used for additional validation or error checking.
• Core / Integration Component: matek.cpp/matek.h appears to be the central component orchestrating the overall expression processing.
• Testing Suite: The tests directory (specifically tests/exprx.cpp) where test cases validate the expression parsing and evaluation logic.
Relationships and Interactions
• The application begins by reading an expression (potentially sourced from "expression.txt" in the root directory) and then feeds it to the Lexer.
• The Lexer breaks down the input into tokens, which the Parser uses to create the AST.
• Operator Handling interacts with the AST to define how mathematical operations are performed.
• Checks may intercept or validate the process at various stages (either during lexing, parsing, or evaluation).
• The "Matek" component serves as the main entry point, coordinating the overall workflow.
• The Testing component simulates usage scenarios and ensures that every component interacts correctly.
Architectural Patterns and Principles
• Modular Design: Each component (lexer, parser, operator handling, checks) is isolated in its own file, reflecting separation of concerns.
• Pipeline Flow: Data flows from one module (input -> lexer -> parser -> evaluation) with clear directional data propagation.
• Error Checking/Validation: The presence of dedicated check functions suggests design for robustness and input validation.
• Test-Driven Development: A tests directory shows that testing is an integral part of the architecture.
Specific Technologies
• C++ as the primary language.
• Premake build system defined via premake5.lua which generates build files for various platforms.
• Compilation relies on a standard C++ compiler, as mentioned in the README.