ANTLR parser option added #4
Closed
orneryd
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
originally from orneryd/Mimir#18
Cypher Parser Modes
NornicDB supports two Cypher parser implementations that can be switched at runtime.
Architecture
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#1f6feb', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#8b949e', 'secondaryColor': '#238636', 'tertiaryColor': '#21262d', 'background': '#0d1117', 'mainBkg': '#161b22'}}}%% flowchart TB subgraph ENV["🔧 Configuration"] direction LR E1["NORNICDB_PARSER"] E2["nornic | antlr"] end Q[/"Cypher Query"/] Q --> VALIDATE["validateSyntax()"] VALIDATE --> |"NORNICDB_PARSER=nornic"| NORNIC VALIDATE --> |"NORNICDB_PARSER=antlr"| ANTLR subgraph NORNIC["⚡ Nornic Parser (Default)"] direction TB N1["String-based validation"] N2["Regex + indexOf"] N3["Direct execution"] N1 --> N2 --> N3 end subgraph ANTLR["🌳 ANTLR Parser"] direction TB A1["ANTLR Lexer"] A2["ANTLR Parser"] A3["Full Parse Tree"] A4["Syntax Validation"] A1 --> A2 --> A3 --> A4 end NORNIC --> EXEC["Execute Query"] ANTLR --> EXEC EXEC --> RESULT[("Result")] style ENV fill:#21262d,stroke:#30363d style NORNIC fill:#161b22,stroke:#238636 style ANTLR fill:#161b22,stroke:#a371f7 style RESULT fill:#238636,stroke:#3fb950Real-World Benchmarks (Northwind Database)
Total test suite time:
Mode Comparison
Configuration
Programmatic Switching
When to Use Each Parser
⚡ Nornic Parser (
NORNICDB_PARSER=nornic) — DefaultUse when:
Pros:
Cons:
🌳 ANTLR Parser (
NORNICDB_PARSER=antlr)Use when:
Pros:
Cons:
Error Message Comparison
Invalid query:
MATCH (n RETURN n(missing closing paren)syntax error: unbalanced parenthesessyntax error: line 1:9 no viable alternative at input 'MATCH (n RETURN'Make Targets
Files
pkg/config/feature_flags.gopkg/cypher/executor.govalidateSyntax()dispatcherpkg/cypher/antlr/pkg/cypher/antlr/*.g4TL;DR: Use
nornic(default) for production. Useantlronly for development/debugging when you need detailed error messages.Beta Was this translation helpful? Give feedback.
All reactions