Skip to content

Instantly share code, notes, and snippets.

@conartist6
Created April 14, 2024 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conartist6/ce8b582ef09483b96553030ebc37060c to your computer and use it in GitHub Desktop.
Save conartist6/ce8b582ef09483b96553030ebc37060c to your computer and use it in GitHub Desktop.
CSTML input stream processing
conartist6@hq bablr-cli % echo '"eat()"' | node bin/index.js -l @bablr/language-bablr-vm-instruction -p Call -f
<!cstml 'https://github.com/bablr-lang/language-bablr-vm-instruction'>
<>
<Call>
callee:
<*Identifier>
'eat'
</>
arguments:
<Tuple>
open:
<*Punctuator balanced=')'>
'('
</>
values[]:
null
close:
<*Punctuator balancer>
')'
</>
</>
</>
</>
conartist6@hq bablr-cli % echo '"eat()"' | node bin/index.js -l @bablr/language-bablr-vm-instruction -p Call -v
resolve($Promise)
advance(<!cstml 'https://github.com/bablr-lang/language-bablr-vm-instruction'>)
<!cstml 'https://github.com/bablr-lang/language-bablr-vm-instruction'>
advance(<>)
<>
--> Call
eat(<*Identifier> 'callee')
advance(<Call>)
<Call>
advance(callee)
callee:
advance(<*Identifier>)
<*Identifier>
--> Identifier
eat(/\w+/)
resolve($Promise)
advance('eat')
'eat'
<-- Identifier
advance(</Identifier>)
</>
eat(<Tuple> 'arguments')
advance(arguments)
arguments:
advance(<Tuple>)
<Tuple>
--> Tuple
eat(<*Punctuator '(' balanced=')'> 'open')
advance(open)
open:
advance(<*Punctuator balanced=')'>)
bindAttribute(balanced ')')
<*Punctuator balanced=')'>
--> Punctuator
eat('(')
advance('(')
'('
<-- Punctuator
advance(</Punctuator>)
</>
eatMatch(<Expression> 'values[]')
branch()
advance(values[])
--> Expression
eat(<Match> null [
(<Array> '[')
(<Object> '{')
(<Tuple> '(')
(<Boolean> /true|false/)
(<Null> 'null')
(<Identifier> /\w/)
])
--> Match
match('[')
match('{')
match('(')
match(/true|false/)
match('null')
match(/\w/)
x-- Match
x-- Expression
reject()
values[]:
null
eat(<*Punctuator ')' balancer> 'close')
advance(close)
close:
advance(<*Punctuator balancer=true>)
bindAttribute(balancer true)
<*Punctuator balancer>
--> Punctuator
eat(')')
advance(')')
')'
<-- Punctuator
advance(</Punctuator>)
</>
<-- Tuple
advance(</Tuple>)
</>
<-- Call
advance(</Call>)
</>
advance(</>)
</>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment