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.

更多信息和选项

  • The following options can be given to CodeParse:
  • "FileFormat"Automaticspecific format to assume for code file
    SourceConvention"LineColumn"convention to use for Source metadata

范例

打开所有单元关闭所有单元

基本范例  (1)

Load the package:

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

Options  (2)

"FileFormat"  (1)

Automatic

XXX "Script"

SourceConvention  (1)

"LineColumn"

"SourceCharacterIndex"

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.