nsbaci 1.0
Loading...
Searching...
No Matches
nsbaci::compiler::Compiler Class Referenceabstract

Abstract base class for all compilers. More...

#include <compiler.h>

Inheritance diagram for nsbaci::compiler::Compiler:

Public Member Functions

 Compiler ()=default
 Default constructor.
virtual ~Compiler ()=default
 Virtual destructor.
virtual CompilerResult compile (const std::string &source)=0
 Compiles source code from a string.
virtual CompilerResult compile (std::istream &input)=0
 Compiles source code from an input stream.

Detailed Description

Abstract base class for all compilers.

The Compiler interface defines the contract for compiling source code into p-code instructions. Implementations handle lexical analysis, parsing, semantic analysis, and code generation.

The compilation process produces:

  • An instruction stream (p-code) for the virtual machine
  • A symbol table mapping variable names to their types and addresses
  • Compilation errors, if there are

Subclasses must implement both compile() overloads to support compilation from both strings and input streams.

Member Function Documentation

◆ compile() [1/2]

virtual CompilerResult nsbaci::compiler::Compiler::compile ( const std::string & source)
pure virtual

Compiles source code from a string.

Performs full compilation including lexical analysis, parsing, semantic analysis, and p-code generation.

Parameters
sourceThe BACI source code to compile.
Returns
CompilerResult containing instructions on success, or errors on failure.

Implemented in nsbaci::compiler::NsbaciCompiler.

◆ compile() [2/2]

virtual CompilerResult nsbaci::compiler::Compiler::compile ( std::istream & input)
pure virtual

Compiles source code from an input stream.

Allows compilation from files or other stream sources.

Parameters
inputThe input stream containing BACI source code.
Returns
CompilerResult containing instructions on success, or errors on failure.

Implemented in nsbaci::compiler::NsbaciCompiler.


The documentation for this class was generated from the following file: