1
1
mirror of https://github.com/github/semantic.git synced 2024-11-23 16:37:50 +03:00
semantic/semantic-parse
Rick Winfrey 9a7ed9d294 Bump to semantic-source 0.1.0
Co-Authored-By: Patrick Thomson <patrickt@users.noreply.github.com>
2020-03-23 13:40:50 -07:00
..
app Get the tests and benchmarks building again 2020-02-20 10:01:46 -08:00
CHANGELOG.md Add a semantic-parse package. 2020-02-04 14:25:39 -05:00
LICENSE Add a semantic-parse package. 2020-02-04 14:25:39 -05:00
README.md Update the references. 2020-02-04 14:28:34 -05:00
semantic-parse.cabal Bump to semantic-source 0.1.0 2020-03-23 13:40:50 -07:00
Setup.hs Add a semantic-parse package. 2020-02-04 14:25:39 -05:00

semantic-parse

This package provides a command line tool that will output ASTs in supported formats.

CLI

To output ASTs, run the semantic-parse 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-parse --format [FORMAT] --sourceFile [FILEPATH]

Source string:

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

An example command is:

semantic-parse -- --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"}))) :| []}))]})