htcc-0.0.0.1: The full scratch implementation of tiny C compiler (x86_64)
Copyright(c) roki 2019
LicenseMIT
Maintainerfalgon53@yahoo.co.jp
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Htcc.Parser.Utils.Core

Description

The utilities of parsing

Synopsis

General utilities of parser

expectedMessage :: Show i => Text -> TokenLC i -> [TokenLC i] -> ASTError i Source #

"expected" error message

Utilities of the token

takeBrace :: forall i. (Integral i, Read i, Show i) => Text -> Text -> [TokenLC i] -> Maybe (Either (TokenLC i) ([TokenLC i], [TokenLC i])) Source #

Extract the partial token enclosed in parentheses from the token sequence. If it is invalid, takeBrace returns (i, Text) indicating the error location. Otherwise, takeBrace returns a partial token enclosed in parentheses and subsequent tokens.

takeExps :: Eq i => [TokenLC i] -> Maybe [[TokenLC i]] Source #

Get arguments from list of Token (e.g: Given the token of f(f(g(a, b)), 42);, return expressions that are the token of "f(g(a, b))" and the token of "42".