Combine a list of Grammar values into a single Seq, flattening
any nested Seq nodes.
import Nld.TokenType exposing (TokenType(..))
seq [ Literal "hello", Literal "world" ]
--> Seq [ Literal "hello", Literal "world" ]
seq [ Literal "a", Seq [ Literal "b", Literal "c" ] ]
--> Seq [ Literal "a", Literal "b", Literal "c" ]Combine a list of Grammar values into a single Choice, flattening
any nested Choice nodes.
import Nld.TokenType exposing (TokenType(..))
choice [ Literal "yes", Literal "no" ]
--> Choice [ Literal "yes", Literal "no" ]
choice [ Literal "a", Choice [ Literal "b", Literal "c" ] ]
--> Choice [ Literal "a", Literal "b", Literal "c" ]Encode a Grammar as a JSON value.
import Json.Encode as Encode
import Nld.TokenType exposing (TokenType(..))
encode (Token NatToken)
--> Encode.object [ ( "tag", Encode.string "token" ), ( "value", Encode.object [ ( "tag", Encode.string "nat" ) ] ) ]
A first-class representation of an NLD-based grammar.