Skip to content

Fix code examples #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ The control flow graph for the parse tree above looks like this.

Each block has a list of its statements.
```
printNode(cfg.blocks[0].statements[0])
console.log(printNode(cfg.blocks[0].statements[0])); // printNode returns a string
```
prints `x, y = 0, 0`.

The methods `cfg.getSuccessors` and `cfg.getPredecessors` allow the edges to be followed forward or backward.
```
const cond = cfg.getSuccessors(cfg.entry)[0];
printNode(cond)
console.log(printNode(cond.statements[0]));
```
prints `x < 10`.

Expand All @@ -63,7 +63,7 @@ The library also provides basic def-use program analysis, namely, tracking where

```
const analyzer = new DataflowAnalyzer();
const flows = analyzer.analyze(cfg).flows;
const flows = analyzer.analyze(cfg).dataflows;
for (let flow of flows.items)
console.log(printNode(flow.fromNode) +
" -----> " + printNode(flow.toNode))
Expand Down