How jigeesharane/mycompiler works
MyCompiler is a small C interpreter for a language with variables, arithmetic, printing, conditionals, and loops. A user supplies source on standard input; the lexer produces tokens, the parser builds an AST, and parser actions print and interpret it. The interpreter evaluates expressions and statements, maintaining variable values and sending program output to standard output. The README documents the language capabilities; the sampled parser excerpt confirms the AST-print and evaluation calls, while lexer and grammar internals were not sampled.
Main entry points: parser.y Parser · interpreter.c Evaluator · lexer.l Lexer · ast.c AST printer
Components 8
AST
- AST nodes
src/ast.c - AST printer
src/ast.c
Interpreter Runtime
- Evaluator
src/interpreter.c - Variable table
src/interpreter.c
Other components
- Program author
- Standard output
Connections 8
- Program author → Lexer: provides source
- Lexer → Parser: returns tokens
- Parser → AST nodes: builds AST
- Parser → AST printer: calls printAST
- Parser → Evaluator: calls evaluate
- Evaluator → Variable table: reads and writes
- AST printer → Standard output: prints AST
- Evaluator → Standard output: prints results