oeneyeC
收藏资源简介:
oeneyec.h — The OneEye Compiler API Specification > Version: 1.0.0 > Module: Core Compilation Engine (oeneyeC) > Description: Standardized header interface for the OneEye Compiler framework, modeled after C standard library headers like <stdio.h>. > 1. Overview The <oeneyec.h> header defines the core data types, error macros, and function prototypes required to initialize, parse, optimize, and emit code using the OneEye Compiler (oeneyeC) toolchain. 2. Constants & Macros | Macro / Constant | Value | Description | |---|---|---| | OEC_OK | 0 | Compilation completed successfully with no errors. | | OEC_ERR_SYNTAX | 1 | Syntax error detected during lexical or syntactic analysis. | | OEC_ERR_TYPE | 2 | Type-checking mismatch or semantic violation. | | OEC_ERR_IO | 3 | Source file could not be read or output stream failed. | | OEC_FLAG_DEBUG | 0x01 | Enables verbose AST printing and compiler debugging logs. | | OEC_FLAG_OPTIMIZE | 0x02 | Enables intermediate representation (IR) optimization passes. | 3. Data Types OEC_Context Represents the active compiler session, handling configuration, symbol tables, and error diagnostics buffers. typedef struct oec_context_t OEC_Context; OEC_Token Represents a single lexical token extracted from the input source stream. typedef enum { OEC_TOK_EOF = 0, OEC_TOK_IDENTIFIER, OEC_TOK_KEYWORD, OEC_TOK_LITERAL_INT, OEC_TOK_OPERATOR, OEC_TOK_PUNCTUATION } OEC_TokenType; typedef struct { OEC_TokenType type; const char* lexeme; int line; int column; } OEC_Token; 4. Core API Function Declarations The following routines form the standard interface of oeneyeC, analogous to standard stream controls in <stdio.h>: Initialization & Destruction * OEC_Context* oec_init(const char* source_path, unsigned int flags); * Description: Allocates and initializes a new compiler context for the target source code file. * void oec_free(OEC_Context* ctx); * Description: Deallocates memory, symbol tables, and internal buffers associated with the compilation context. Compilation Pipeline Phases * int oec_lex(OEC_Context* ctx); * Description: Executes lexical analysis, breaking the input stream down into recognizable token nodes. * int oec_parse(OEC_Context* ctx); * Description: Constructs and validates the Abstract Syntax Tree (AST) from the token stream. * int oec_emit(OEC_Context* ctx, const char* output_path); * Description: Generates target machine code or bytecode and writes the binary stream to the specified path. High-Level Wrapper * int oec_compile_file(const char* input_path, const char* output_path, unsigned int flags); * Description: A monolithic convenience wrapper that executes the entire end-to-end compilation pipeline. Returns OEC_OK on success.



