CodeParser`
CodeParser`

CodeParse

CodeParse["code"]

parses a string of WL code returning an abstract syntax tree.

CodeParse[File[src]]

parses a file of WL code returning an abstract syntax tree.

Details and Options

  • The following options can be given to CodeParse:
  • SourceConvention "LineColumn"convention to use for Source metadata

Examples

open allclose all

Basic Examples  (1)

Load the package:

Parse a string of Wolfram Language code into an abstract syntax tree:

Options  (1)

SourceConvention  (1)

Using "LineColumn" convention:

Using "SourceCharacterIndex" convention:

Properties & Relations  (1)

The following three code strings parse in a similar manner:

The location of the tokens in the source are different for each source, so they are not identical:

Possible Issues  (1)

A string representing a file path is treated as code.

File paths must use the File wrapper.