Demos¶
The .NET edition ships with ~18 sample programs under gsp_demo_dotnet/src/demos/ in the source repository. They show idiomatic C# usage of TGSqlParser for the most common workflows: formatting, lexing, lineage, AST traversal, statement rewriting, and more.
Running a demo¶
Each demo is a self-contained net10.0 console app with a ProjectReference to the library. Run any of them with dotnet run:
1 2 3 4 5 6 7 8 | |
What's in the box¶
| Demo | What it shows |
|---|---|
formatsql |
Pretty-print SQL using the pp/ formatter |
checksyntax |
Bare-minimum syntax-validation pattern |
lexer (in tools/) |
Tokenise SQL via TGSqlParser.tokenizeSqltext() |
extractTableColumns |
Walk the AST to extract every table/column reference |
gettablecolumns |
Variant that distinguishes input vs output columns |
tableColumnRename |
Modify the AST (rename a table) and re-emit via TScriptGenerator |
removeColumn |
Drop a column from every SELECT/INSERT in a script |
removeCondition |
Strip a WHERE condition from a query |
removevars |
Resolve and remove SQL variables |
convertJoin |
Convert Oracle (+) outer-joins to ANSI joins |
dataFlowAnalyzer |
Full column-level data lineage analysis |
dlineage / dlineageRelation |
Older lineage demos kept for backwards compatibility |
dlineageCommon |
Shared lineage helper library used by the demos above |
columnImpact |
"If I drop this column, what queries break?" analysis |
expressionTraverser |
Walk every expression in a script with custom logic |
joinRelationAnalyze |
Extract join graphs from arbitrary SQL |
analyzesp |
Stored-procedure analysis (input/output parameters, called procedures) |
listGSPInfo |
Dump library version and supported vendor list |
scriptWriter |
Round-trip a script through the parser and the script writer |
visitors |
Visitor-pattern walkthrough (XML-emitting visitor) |
Reading the source¶
Every demo is < 200 lines of C#. Two recommended starting points:
formatsql/formatsql.cs— the simplest end-to-end example: parse a file, format it, write it out. About 100 lines.extractTableColumns/— the canonical AST-walking example.
See also¶
- Tutorials — for guided walkthroughs of these patterns
- API Reference — for the full API surface
gsp_demo_dotnet/README.md— the demo-tree readme