Next: , Previous: , Up: The Dezyne command-line tools   [Contents][Index]


9.7 Invoking dzn parse

The dzn parse command parses a Dezyne file and reports any errors, both syntax errors as well as “well-formedness” errors. The Dezyne parser consists of three stages:

  1. The PEG parser creates a raw parse-tree10,
  2. The parse-tree is converted into the abstract syntax tree (AST),
  3. A number of so-called “well-formedness” checks are performed on the AST that ascertain type correctness and detect semantic errors (See Well-formedness),
  4. After parsing, some commands perform a normalization on the AST.

The well-formedness checking of a large program can take a significant amount of time. As the well-formedness check does not change a correct AST in any way, it can be safely skipped when parsing a previously checked and unmodified program (See Invoking dzn).

Usually, the parser is invoked implicitly by commands like dzn verify and dzn code. It can be useful to do an explicit check for errors, for example after saving a Dezyne file (See The Perfect Setup). Its syntax is:

dzn dzn-option… parse optionFILE

The options can be among the following:

--preprocess
-E

Resolve imports and produce a content stream. This pre-processed content can also be processed later by the parser and it has the advantage of being independent of the file-system.

--help
-h

Display help on invoking dzn parse, and then exit.

--import=dir
-I dir

Add directory dir to the import path.

--list-models

List the Dezyne models defined in the file, with their type.

--locations
-L

Show locations in output ast.

--model=model
-m model

Only output ast for model model.

--parse-tree
-t

Write the raw peg parse tree, skip generating a full ast,

--output=file
-o file

Write ast to file, use “-” for standard output.


Footnotes

(10)

The dzn language command (See Invoking dzn language) works on this raw parse-tree.


Next: Invoking dzn simulate, Previous: Invoking dzn lts, Up: The Dezyne command-line tools   [Contents][Index]