|
Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
|
Conflict detection for the extension system. More...
#include <stdint.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | Conflict |
| Description of a single conflict between modifications. More... | |
| struct | ConflictPoint |
| A specific ambiguity where multiple grammars can handle the same token in the same parser state. More... | |
| struct | ConflictSet |
| Collection of detected conflicts. More... | |
| struct | LimeContext |
| A grammar context – one possible interpretation of a token within a particular grammar/extension. More... | |
| struct | MultiGrammarConflictResult |
| Result of a multi-grammar conflict scan. More... | |
Typedefs | |
| typedef uint32_t | ExtensionID |
| Opaque ID identifying a registered extension. | |
Enumerations | |
| enum | ConflictLevel { CONFLICT_LEVEL_TOKEN = 0 , CONFLICT_LEVEL_RULE = 1 , CONFLICT_LEVEL_SEMANTIC = 2 } |
| Conflict detection levels for multi-grammar scenarios. More... | |
| enum | ConflictType { CONFLICT_TOKEN_COLLISION , CONFLICT_DUPLICATE_RULE , CONFLICT_PRECEDENCE_CLASH , CONFLICT_SHIFT_REDUCE , CONFLICT_REDUCE_REDUCE } |
| Types of conflicts that can occur between grammar extensions. More... | |
Functions | |
| bool | conflict_point_add_context (ConflictPoint *cp, const LimeContext *ctx) |
| Add a grammar context to a conflict point. | |
| void | conflict_point_destroy (ConflictPoint *cp) |
| Free resources owned by a ConflictPoint. | |
| void | conflict_point_init (ConflictPoint *cp, uint16_t token, int state, ConflictLevel level) |
| Initialize a ConflictPoint. | |
| bool | conflict_set_add (ConflictSet *cs, ConflictType type, uint32_t mod_index_a, uint32_t mod_index_b, ExtensionID ext_id_a, ExtensionID ext_id_b, const char *description) |
| Add a conflict to the set. | |
| ConflictSet * | conflict_set_create (void) |
| Create an empty conflict set. | |
| void | conflict_set_destroy (ConflictSet *cs) |
| Destroy a conflict set and free all owned memory. | |
| uint32_t | conflict_set_unresolved_count (const ConflictSet *cs) |
| Return the number of unresolved conflicts in the set. | |
| bool | detect_all_multi_grammar_conflicts (struct ExtensionRegistry *reg, MultiGrammarConflictResult *result) |
| Run a full multi-grammar conflict scan across all loaded extensions. | |
| ConflictPoint | detect_conflict (struct ExtensionRegistry *reg, uint16_t token, int state) |
| Detect all levels of conflict for a specific token and state. | |
| bool | detect_conflicts (const struct GrammarModification *mods, uint32_t nmods, ConflictSet *cs) |
| Scan modifications for conflicts. | |
| uint32_t | detect_rule_conflicts (struct ExtensionRegistry *reg, uint16_t token, int state, MultiGrammarConflictResult *result) |
| Detect rule-level conflicts for a given token and state. | |
| uint32_t | detect_semantic_conflicts (struct ExtensionRegistry *reg, uint16_t token, int state, MultiGrammarConflictResult *result) |
| Detect semantic-level conflicts for a given token and state. | |
| uint32_t | detect_token_conflicts (struct ExtensionRegistry *reg, MultiGrammarConflictResult *result) |
| Detect token-level conflicts across all loaded extensions. | |
| MultiGrammarConflictResult * | multi_conflict_result_create (void) |
| Create an empty result set. | |
| void | multi_conflict_result_destroy (MultiGrammarConflictResult *result) |
| Destroy a result set and free all owned memory. | |
| uint32_t | resolve_conflicts (ConflictSet *cs, const struct GrammarModification *mods, uint32_t nmods, struct ExtensionRegistry *registry) |
| Attempt to resolve conflicts via extension callbacks. | |
Conflict detection for the extension system.
When multiple extensions modify a grammar, conflicts can arise:
detect_conflicts() scans an array of modifications and reports all conflicts found. Extensions can resolve conflicts via their on_conflict callback.
| Level | Description |
|---|---|
| TOKEN | Same lexeme maps to different tokens in different grammars |
| RULE | A token sequence can be parsed by rules from different grammars |
| SEMANTIC | Same syntactic construct carries different semantic actions |
Definition in file conflict.h.
| typedef uint32_t ExtensionID |
Opaque ID identifying a registered extension.
0 = base grammar.
Definition at line 39 of file conflict.h.