@bablr/cli

0.6.5 • Public • Published

@bablr/cli

This is the CLI runner for BABLR. If you have a BABLR grammar for a computer language, this tool allows you to use it to do streaming parsing. Parse results are presented in CSTML.

Usage

This package has no built-in language support, but rather expects you to supply a valid import specifier referring to a BABLR language. This likely means that you will likely need to start by installing both the parser and the language you wish to use.

Usage: bablr [options]

Options:
  -l, --language [URL]     The URL of the top BABLR language
  -p, --production [type]  The name of the top production type
  -f, --format             Pretty-format CSTML output (default: true)
  -F, --no-format
  -v, --verbose            Prints debugging information to stderr
  -c, --color [WHEN]       When to use ANSI escape colors
    WHEN: "auto" | "always" | "never" (default: "auto")
  -e, --embedded           Requires quoted input but enables gap parsing
  -h, --help               display help for command

Example

bablr -l @bablr/language-en-json -p Expression -f << 'EOF'
[
  1,
  true,
  "3"
]
EOF

Running the above command produces the following output. Note that this is a stream parse so lines of output will appear one by one as fast as the input can be read and parsed.

<!0:cstml bablr-language='https://github.com/bablr-lang/language-en-json'>
<>
  .:
  <Array>
    openToken: <*Punctuator '[' balanced=']' />
    <#*Space:Space '\n  ' />
    separators[]: []
    elements[]: []
    elements[]:
    <Number span='Number'>
      wholePart:
      <Integer>
        signToken: null
        value: <*UnsignedInteger '1' />
      </>
      fractionalSeparatorToken: null
      fractionalPart: null
      exponentSeparatorToken: null
      exponentPart: null
    </>
    separators[]: <*Punctuator ',' />
    <#*Space:Space '\n  ' />
    elements[]:
    <Boolean>
      sigilToken: <*Keyword 'true' />
    </>
    separators[]: <*Punctuator ',' />
    <#*Space:Space '\n  ' />
    elements[]:
    <String>
      openToken: <*Punctuator '"' balanced='"' balancedSpan='String' />
      content: <*StringContent '3' />
      closeToken: <*Punctuator '"' balancer />
      <#*Space:Space '\n' />
    </>
    closeToken: <*Punctuator ']' balancer />
  </>
</>

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.6.557latest

Version History

VersionDownloads (Last 7 Days)Published
0.6.557
0.6.45
0.6.31
0.6.21
0.6.10
0.6.00
0.5.00
0.4.60
0.4.51
0.4.41
0.4.30
0.4.20
0.4.10
0.4.01
0.3.11
0.3.00
0.2.10
0.2.01
0.1.110
0.1.100
0.1.91
0.1.81
0.1.72
0.1.61
0.1.51
0.1.42
0.1.32
0.1.21
0.1.11
0.1.02

Package Sidebar

Install

npm i @bablr/cli

Weekly Downloads

83

Version

0.6.5

License

MIT

Unpacked Size

11.7 kB

Total Files

5

Last publish

Collaborators

  • conartist6
  • stirlhoss