-
Notifications
You must be signed in to change notification settings - Fork 14
[Query] Normalized AST
This document was generated from 'src/documentation/wiki-query.ts' on 2026-07-20, 13:05:03 UTC presenting an overview of flowR's query API (v2.12.3). Please do not edit this file/wiki page directly.
Normalized AST Query [overview]
Returns the normalized AST of the given code.
This query is requested with the type normalized-ast.
Maybe you want to handle only the result of the query execution, or you just need the normalized AST again. This query type does exactly that!
Using the example code x + 1, the following query returns the normalized AST of the code:
[ { "type": "normalized-ast" } ](This can be shortened to @normalized-ast when used with the REPL command :query).
Results (prettified and summarized):
Query: normalized-ast (1 ms)
╰ Normalized AST
All queries together required ≈1 ms (1ms accuracy, total 2 ms)
Show Detailed Results as Json
The analysis required 1.5 ms (including parsing and normalization and the query) within the generation environment.
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.
As the code is pretty long, we inhibit pretty printing and syntax highlighting (JSON, hiding built-in):
{"normalized-ast":{".meta":{"timing":1},"normalized":{"ast":{"type":"RProject","files":[{"root":{"type":"RExpressionList","children":[{"type":"RBinaryOp","location":[1,3,1,3],"lhs":{"type":"RSymbol","location":[1,1,1,1],"content":"x","lexeme":"x","info":{"fullRange":[1,1,1,1],"adToks":[],"id":0,"parent":2,"role":"bin-l","index":0,"nest":0}},"rhs":{"location":[1,5,1,5],"lexeme":"1","info":{"fullRange":[1,5,1,5],"adToks":[],"id":1,"parent":2,"role":"bin-r","index":1,"nest":0},"type":"RNumber","content":{"num":1,"complexNumber":false,"markedAsInt":false}},"operator":"+","lexeme":"+","info":{"fullRange":[1,1,1,5],"adToks":[],"id":2,"parent":3,"nest":0,"index":0,"role":"el-c"}}],"info":{"adToks":[],"id":3,"nest":0,"role":"root","index":0}}}],"info":{"id":4}},"idMap":{"size":4,"k2v":[[0,{"type":"RSymbol","location":[1,1,1,1],"content":"x","lexeme":"x","info":{"fullRange":[1,1,1,1],"adToks":[],"id":0,"parent":2,"role":"bin-l","index":0,"nest":0}}],[1,{"location":[1,5,1,5],"lexeme":"1","info":{"fullRange":[1,5,1,5],"adToks":[],"id":1,"parent":2,"role":"bin-r","index":1,"nest":0},"type":"RNumber","content":{"num":1,"complexNumber":false,"markedAsInt":false}}],[2,{"type":"RBinaryOp","location":[1,3,1,3],"lhs":{"type":"RSymbol","location":[1,1,1,1],"content":"x","lexeme":"x","info":{"fullRange":[1,1,1,1],"adToks":[],"id":0,"parent":2,"role":"bin-l","index":0,"nest":0}},"rhs":{"location":[1,5,1,5],"lexeme":"1","info":{"fullRange":[1,5,1,5],"adToks":[],"id":1,"parent":2,"role":"bin-r","index":1,"nest":0},"type":"RNumber","content":{"num":1,"complexNumber":false,"markedAsInt":false}},"operator":"+","lexeme":"+","info":{"fullRange":[1,1,1,5],"adToks":[],"id":2,"parent":3,"nest":0,"index":0,"role":"el-c"}}],[3,{"type":"RExpressionList","children":[{"type":"RBinaryOp","location":[1,3,1,3],"lhs":{"type":"RSymbol","location":[1,1,1,1],"content":"x","lexeme":"x","info":{"fullRange":[1,1,1,1],"adToks":[],"id":0,"parent":2,"role":"bin-l","index":0,"nest":0}},"rhs":{"location":[1,5,1,5],"lexeme":"1","info":{"fullRange":[1,5,1,5],"adToks":[],"id":1,"parent":2,"role":"bin-r","index":1,"nest":0},"type":"RNumber","content":{"num":1,"complexNumber":false,"markedAsInt":false}},"operator":"+","lexeme":"+","info":{"fullRange":[1,1,1,5],"adToks":[],"id":2,"parent":3,"nest":0,"index":0,"role":"el-c"}}],"info":{"adToks":[],"id":3,"nest":0,"role":"root","index":0}}]],"v2k":{}},".meta":{"timing":0}}},".meta":{"timing":1}}
Original Code
x + 1Dataflow Graph of the R Code
The analysis required 1.2 ms (including parse and normalize, using the r-shell engine) within the generation environment. No signature database is mounted for these generated graphs, so library() calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. acf as stats::acf).
We encountered no unknown side effects during the analysis.
flowchart LR
0(["`*#91;RSymbol#93;* **x**
*1.1* (**id: 0**)`"])
%% No edges found for 0
1{{"`*#91;RNumber#93;* **1**
*1.5* (**id: 1**)`"}}
%% No edges found for 1
2[["`*#91;RBinaryOp#93;* base#58;#58;**#43;**
*1.1-5* (**id: 2**)
arg: (0, 1)`"]]
built-in:_["`Built-In:
#43;`"]
style built-in:_ stroke:gray,fill:gray,stroke-width:2px,opacity:.8;
2 -->|"reads, arg"| 0
2 -->|"reads, arg"| 1
2 -.->|"reads, calls"| built-in:_
linkStyle 2 stroke:gray;
Implementation Details
Responsible for the execution of the Normalized AST Query query is executeNormalizedAstQuery in ./src/queries/catalog/normalized-ast-query/normalized-ast-query-executor.ts.
Currently maintained by Florian Sihler and Oliver Gerstl at Ulm University
Email | GitHub | Penguins | Portfolio
- 🧑💻 Developer Onboarding
- 💻 Setup
- 👓 Overview
- 🪟 Interfacing with flowR
- 🌋 Core
- 🧹 Testing & Linting (Benchmark Page)
⁉️ FAQ- ℹ️ Extra Information