Skip to content

tcr/jast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jast, a JavaScript parser, AST, and tools

Credit to UglifyJS by mishoo for the parser base. jast is released under the modified BSD license.

AST Definition

Each AST node is a JSON hash with the property "type" corresponding to the node type ("script-context", "sub-op-expr", etc) and the property "ln" corresponding to line number. Each node has properties about the node as described below:

Contexts

  • script-context: {Array stats}
  • closure-context: {String name, Array<String> args, Array stats}

Literals

  • num-literal: {Number value}
  • str-literal: {String value}
  • obj-literal: {Array<{String value, node expr}> props}
  • array-literal: {Array<node> exprs}
  • undef-literal: {}
  • null-literal: {}
  • boolean-literal: {Boolean value}
  • func-literal: {node closure}
  • regex-literal: {String expr, String flags}

Operations

  • num-op-expr: {node expr}
  • neg-op-expr: {node expr}
  • not-op-expr: {node expr}
  • bit-not-op-expr: {node expr}
  • typeof-op-expr: {node left, node right}
  • void-op-expr: {node left, node right}
  • lt-op-expr: {node left, node right}
  • lte-op-expr: {node left, node right}
  • gt-op-expr: {node left, node right}
  • gte-op-expr: {node left, node right}
  • eq-op-expr: {node left, node right}
  • eqs-op-expr: {node left, node right}
  • neq-op-expr: {node left, node right}
  • neqs-op-expr: {node left, node right}
  • add-op-expr: {node left, node right}
  • sub-op-expr: {node left, node right}
  • mul-op-expr: {node left, node right}
  • div-op-expr: {node left, node right}
  • mod-op-expr: {node left, node right}
  • lsh-op-expr: {node left, node right}
  • rsh-op-expr: {node left, node right}
  • bit-and-op-expr: {node left, node right}
  • bit-or-op-expr: {node left, node right}
  • bit-xor-op-expr: {node left, node right}
  • or-op-expr: {node left, node right}
  • and-op-expr: {node left, node right}
  • instanceof-op-expr: {node left, node right}
  • in-op-expr: {node left, node right}
  • seq-op-expr: {node left, node right}

Expressions

  • num-op-expr: {node expr}
  • neg-op-expr: {node expr}
  • not-op-expr: {node expr}
  • bit-not-op-expr: {node expr}
  • typeof-op-expr: {node left, node right}
  • void-op-expr: {node left, node right}
  • lt-op-expr: {node left, node right}
  • lte-op-expr: {node left, node right}
  • gt-op-expr: {node left, node right}
  • gte-op-expr: {node left, node right}
  • eq-op-expr: {node left, node right}
  • eqs-op-expr: {node left, node right}
  • neq-op-expr: {node left, node right}
  • neqs-op-expr: {node left, node right}
  • add-op-expr: {node left, node right}
  • sub-op-expr: {node left, node right}
  • mul-op-expr: {node left, node right}
  • div-op-expr: {node left, node right}
  • mod-op-expr: {node left, node right}
  • lsh-op-expr: {node left, node right}
  • rsh-op-expr: {node left, node right}
  • bit-and-op-expr: {node left, node right}
  • bit-or-op-expr: {node left, node right}
  • bit-xor-op-expr: {node left, node right}
  • or-op-expr: {node left, node right}
  • and-op-expr: {node left, node right}
  • instanceof-op-expr: {node left, node right}
  • in-op-expr: {node left, node right}
  • seq-op-expr: {node left, node right}
  • this-expr: {}
  • call-expr: {node expr, Array<node> args}
  • new-expr: {node constructor, Array<node> args}
  • if-expr: {node expr, node thenExpr, node elseExpr}
  • scope-ref-expr: {String value}
  • static-ref-expr: {node base, String value}
  • dyn-ref-expr: {node base, node index}
  • static-method-call-expr: {node base, String value, Array<node> args}
  • dyn-method-call-expr: {node base, node index, Array<node> args}
  • scope-delete-expr: {String value}
  • static-delete-expr: {node base, String value}
  • dyn-delete-expr: {node base, node index}
  • scope-assign-expr: {String value, node expr}
  • static-assign-expr: {node base, String value, node expr}
  • dyn-assign-expr: {node base, node index, node expr}
  • scope-inc-expr: {Boolean pre, Number inc, String value}
  • static-inc-expr: {Boolean pre, Number inc, node base, String value}
  • dyn-inc-expr: {Boolean pre, Number inc, node base, node index}

Statements

  • block-stat: {Array<node> stats}
  • expr-stat: {node expr}
  • ret-stat: {node expr}
  • if-stat: {node expr, node thenStat, node elseStat}
  • while-stat: {node expr, node stat}
  • do-while-stat: {node expr, node stat}
  • for-stat: {node init, node expr, node step, node stat}
  • for-in-stat: {Boolean isvar, String value, node expr, node stat}
  • switch-stat: {node expr, Array<{node match, node stat}> cases}
  • throw-stat: {node expr}
  • try-stat: {node tryStat, {String value, node stat} catchBlock, node finallyStat}
  • var-stat: {Array<{String value, node expr}> vars}
  • defn-stat: {node closure}
  • label-stat: {String name, node stat}
  • break-stat: {String label}
  • continue-stat: {String label}

About

A well-defined JavaScript parser, AST, and tools.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published