/ README.md
README.md
1 # @bablr/cli 2 3 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. 4 5 ## Usage 6 7 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. 8 9 ``` 10 Usage: bablr [options] 11 12 Options: 13 -l, --language [URL] The URL of the top BABLR language 14 -p, --production [type] The name of the top production type 15 -f, --format Pretty-format CSTML output (default: true) 16 -F, --no-format 17 -v, --verbose Prints debugging information to stderr 18 -c, --color [WHEN] When to use ANSI escape colors 19 WHEN: "auto" | "always" | "never" (default: "auto") 20 -e, --embedded Requires quoted input but enables gap parsing 21 -h, --help display help for command 22 ``` 23 24 ## Example 25 26 ```bash 27 bablr -l @bablr/language-en-json -p Expression -f << 'EOF' 28 [ 29 1, 30 true, 31 "3" 32 ] 33 EOF 34 ``` 35 36 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. 37 38 ```cstml 39 <!0:cstml bablr-language='https://github.com/bablr-lang/language-en-json'> 40 <> 41 .: 42 <Array> 43 openToken: <*Punctuator '[' balanced=']' /> 44 <#*Space:Space '\n ' /> 45 separators[]: [] 46 elements[]: [] 47 elements[]: 48 <Number span='Number'> 49 wholePart: 50 <Integer> 51 signToken: null 52 value: <*UnsignedInteger '1' /> 53 </> 54 fractionalSeparatorToken: null 55 fractionalPart: null 56 exponentSeparatorToken: null 57 exponentPart: null 58 </> 59 separators[]: <*Punctuator ',' /> 60 <#*Space:Space '\n ' /> 61 elements[]: 62 <Boolean> 63 sigilToken: <*Keyword 'true' /> 64 </> 65 separators[]: <*Punctuator ',' /> 66 <#*Space:Space '\n ' /> 67 elements[]: 68 <String> 69 openToken: <*Punctuator '"' balanced='"' balancedSpan='String' /> 70 content: <*StringContent '3' /> 71 closeToken: <*Punctuator '"' balancer /> 72 <#*Space:Space '\n' /> 73 </> 74 closeToken: <*Punctuator ']' balancer /> 75 </> 76 </> 77 ```