| Safe Haskell | Safe-Inferred |
|---|
Derive.Parse
Contents
Description
Tracklang parsers. Many of the parsers in here should be inverses of
the ShowVal.ShowVal class.
Synopsis
- parse_expr :: Text -> Either Text DeriveT.Expr
- parse_val :: Text -> Either Text DeriveT.Val
- parse_attrs :: String -> Either Text Attrs.Attributes
- parse_num :: Text -> Either Text Signal.Y
- parse_call :: Text -> Maybe Text
- lex1 :: Text -> (Text, Text)
- lex :: Text -> [Text]
- split_pipeline :: Text -> [[Text]]
- join_pipeline :: [[Text]] -> Text
- unparsed_call :: Expr.Symbol
- lexeme :: A.Parser a -> A.Parser a
- p_pipe :: A.Parser ()
- p_expr :: Bool -> A.Parser DeriveT.Expr
- p_pcontrol_ref :: A.Parser DeriveT.PControlRef
- p_identifier :: Bool -> String -> A.Parser Text
- p_symbol :: Bool -> A.Parser Expr.Symbol
- expand_macros :: (Text -> Text) -> Text -> Either Text Text
- p_val :: A.Parser DeriveT.Val
- p_unparsed_expr :: A.Parser DeriveT.Call
- p_null_call :: A.Parser (Expr.Call a)
- p_single_quote_string :: A.Parser Text
- p_equal_generic :: A.Parser a -> A.Parser (Expr.Str, Maybe Expr.Str, [a])
- empty_line :: A.Parser ()
- spaces :: A.Parser ()
Documentation
parse_expr :: Text -> Either Text DeriveT.Expr Source #
parse_attrs :: String -> Either Text Attrs.Attributes Source #
Parse attributes in the form +a+b.
parse_num :: Text -> Either Text Signal.Y Source #
Parse a number or hex code, without a type suffix.
lex1 :: Text -> (Text, Text) Source #
Lex out a single expression. This isn't really a traditional lex, because it will extract a whole parenthesized expression instead of a token. Also, this leaves on trailing whitespace, so you can concatenate the lexed out words and get the original input back.
split_pipeline :: Text -> [[Text]] Source #
Take an expression and lex it into words, where each sublist corresponds
to one expression in the pipeline. Like lex1, this corresponds to call
name and arguments, not tokens. The final word could be a comment.
This preserves trailing spaces on the words, because track editors use that to infer edits in progress.
join_pipeline :: [[Text]] -> Text Source #
unparsed_call :: Expr.Symbol Source #
This is a magic call name that suppresses normal parsing. Instead, the rest of the event expression is passed as a string. The only characters that can't be used are ) and |, so an unparsed call can still be included in a sub expression.
parsers
p_pcontrol_ref :: A.Parser DeriveT.PControlRef Source #
Unlike p_control_ref, this doesn't parse a comma and a default value,
because pitches don't have literals. Instead, use the # val call.
p_identifier :: Bool -> String -> A.Parser Text Source #
Identifiers are somewhat more strict than usual. They must be lowercase, and the only non-letter allowed is hyphen. This means words must be separated with hyphens, and leaves me free to give special meanings to underscores or caps if I want.
until gives additional chars that stop parsing, for idents that are
embedded in another lexeme.
Arguments
| :: Bool | A call at the top level can allow a ). |
| -> A.Parser Expr.Symbol |
Any word in call position is considered a Str. This means that
you can have calls like 4 and >, which are useful names for notes or
ornaments.
expand macros
expand_macros :: (Text -> Text) -> Text -> Either Text Text Source #
Map the identifiers after a "@" through the given function. Used to implement ID macros for the REPL.
A macro looks like @valid-id-chars.
for Parse.Ky
p_unparsed_expr :: A.Parser DeriveT.Call Source #
Parse a unparsed_call.
p_null_call :: A.Parser (Expr.Call a) Source #
empty_line :: A.Parser () Source #