1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 17:05:33 +03:00
semantic/semantic-ast
2020-02-04 14:13:10 -05:00
..
app remove unnecessary qualifier 2020-02-03 16:14:14 -05:00
src Add a module header describing the organizational concerns. 2020-02-04 14:13:10 -05:00
CHANGELOG.md create semantic-ast 2019-09-10 14:07:58 -04:00
LICENSE Update LICENSE 2019-10-16 13:56:40 -04:00
README.md clean up readme 2019-10-16 11:53:38 -04:00
semantic-ast.cabal Stub in a module for just the Traversable1 class. 2020-02-04 14:11:43 -05:00
Setup.hs create semantic-ast 2019-09-10 14:07:58 -04:00

semantic-ast

This package has two goals:

  1. Develop a library that will produce ASTs;
  2. Provide a command line tool that will output ASTs in supported formats.

CLI

To output ASTs, run the semantic-ast command, specifying two mandatory options: 1) the format you'd like to return (ex., Show, JSON, etc.) and 2) the option specifying whether the source code will be passed in directly via command line (using --sourceString) or via providing the file path --sourceFile.

Filepath:

semantic-ast --format [FORMAT] --sourceFile [FILEPATH]

Source string:

semantic-ast --format [FORMAT] --sourceString [SOURCE]

An example command is:

semantic-ast -- --format Show --sourceString "a"

This will generate an AST

Right (Module {ann = (Range {start = 0, end = 1},Span {start = Pos {line = 0, column = 0}, end = Pos {line = 0, column = 1}}), extraChildren = [R1 (ExpressionStatementSimpleStatement (ExpressionStatement {ann = (Range {start = 0, end = 1},Span {start = Pos {line = 0, column = 0}, end = Pos {line = 0, column = 1}}), extraChildren = L1 (PrimaryExpressionExpression (IdentifierPrimaryExpression (Identifier {ann = (Range {start = 0, end = 1},Span {start = Pos {line = 0, column = 0}, end = Pos {line = 0, column = 1}}), bytes = "a"}))) :| []}))]})