← ClaudeAtlas

parser-and-nodeslisted

Hack the PostgreSQL parser or add a new Node type — covers scan.l flex tokenizer, gram.y bison grammar, parse_analyze in analyze.c, kwlist.h keywords, and adding/modifying Node types in parsenodes.h / primnodes.h / plannodes.h that flow through copy/equal/out/read funcs auto-generated by gen_node_support.pl. Spans the AST→Query→Plan three-tree pipeline, mutator/walker conventions (expression_tree_walker, query_tree_mutator), the node-type reference table, List/lappend/foreach idioms, and shift-reduce conflict resolution. Use whenever a PG patch edits src/backend/parser/**, edits src/include/nodes/*.h, adds a new SQL keyword to kwlist.h, extends a parse-tree node, writes a tree mutator/walker, or resolves a gram.y shift-reduce conflict. Skip for non-PG parsers (ANTLR, Babel, nom, tree-sitter, LALRPOP, Yacc/Bison on other projects, LLVM IR / Clang AST), JSON / XML / YAML parsing, and executor-node additions (use executor-and-planner instead).
matejformanek/postgres-claude · ★ 0 · Data & Documents · score 70
Install: claude install-skill matejformanek/postgres-claude
# Parser & Node-types — operational Companion docs: `knowledge/idioms/parser-pipeline.md`, `knowledge/idioms/node-types-and-lists.md`. ## 0. The three-tree pipeline — AST → Query → Plan Every SQL statement flows through three distinct tree shapes; nodes in each header live or die at a specific stage. Confuse the stages and your patch will silently fail in a downstream walker. ``` SQL text │ │ gram.y / scan.l / kwlist.h ▼ 1. Raw parsetree (AST) — parsenodes.h utility-stmt nodes Examples: SelectStmt, + A_Expr / A_Const / ColumnRef / InsertStmt, A_Expr, FuncCall (raw expression shapes) ColumnRef, FuncCall → walker: raw_expression_tree_walker No types resolved, no relations looked up, no operators resolved. │ │ parser/analyze.c → transformStmt → transform<Foo>Stmt │ parser/parse_*.c → adds rangetable, resolves names, │ picks operator + cast OIDs, │ applies coercions ▼ 2. Query tree — parsenodes.h Query + analyzed Examples: Query, RangeTblEntry, expression nodes (primnodes.h) Var, OpExpr, Const, FuncExpr, Examples: Var, OpExpr, Const, TargetEntry, FromExpr, JoinExpr FuncExpr, Aggref, WindowFunc → walker: expression_tree_walker + query_tree_walker