trying to do more for js parser
This commit is contained in:
parent
2d2d0c0969
commit
1f89316fdf
2 changed files with 5 additions and 3 deletions
|
|
@ -12,7 +12,7 @@ import Control.Applicative (Alternative (many), optional, (<|>))
|
||||||
import Control.Monad.Trans.Class (MonadTrans (lift))
|
import Control.Monad.Trans.Class (MonadTrans (lift))
|
||||||
import Control.Monad.Trans.State (StateT, evalStateT, put)
|
import Control.Monad.Trans.State (StateT, evalStateT, put)
|
||||||
import Data.Data (Proxy (Proxy))
|
import Data.Data (Proxy (Proxy))
|
||||||
import Data.Functor ((<&>))
|
import Data.Functor (void, (<&>))
|
||||||
import Data.Maybe (maybeToList)
|
import Data.Maybe (maybeToList)
|
||||||
import Data.String (IsString (fromString))
|
import Data.String (IsString (fromString))
|
||||||
import Data.Void (Void)
|
import Data.Void (Void)
|
||||||
|
|
@ -20,7 +20,7 @@ import Logger
|
||||||
import Text.Megaparsec (MonadParsec (notFollowedBy, try), ParseErrorBundle, ParsecT, Stream (tokensToChunk), anySingle, choice, parse, runParserT)
|
import Text.Megaparsec (MonadParsec (notFollowedBy, try), ParseErrorBundle, ParsecT, Stream (tokensToChunk), anySingle, choice, parse, runParserT)
|
||||||
import qualified Text.Megaparsec as MP
|
import qualified Text.Megaparsec as MP
|
||||||
import Text.Megaparsec.Char (char, digitChar, eol, hspace, letterChar, newline, string)
|
import Text.Megaparsec.Char (char, digitChar, eol, hspace, letterChar, newline, string)
|
||||||
import Utilities.Parsing (Characters, ToText (fromText, toString, toText))
|
import Utilities.Parsing (Characters, ToChar (fromChar), ToText (fromText, toString, toText))
|
||||||
|
|
||||||
data Possibility = ExprAllowed | ExprNotAllowed deriving (Eq)
|
data Possibility = ExprAllowed | ExprNotAllowed deriving (Eq)
|
||||||
|
|
||||||
|
|
@ -375,7 +375,7 @@ literal =
|
||||||
char '`'
|
char '`'
|
||||||
pure $ TemplateTail $ fromText $ mconcat $ map toText $ contents
|
pure $ TemplateTail $ fromText $ mconcat $ map toText $ contents
|
||||||
template_char :: Parser s m s
|
template_char :: Parser s m s
|
||||||
template_char = fromText . toText <$> choice [try (string "$" <* (notFollowedBy $ char '{')), try (char '\\' *> ((try template_escape_seq) <|> not_escape_seq)), try ((optional $ char '\\') *> (eol)), source_char]
|
template_char = fromText . toText <$> choice [try (string "$" <* (notFollowedBy $ char '{')), try (char '\\' *> ((try template_escape_seq) <|> not_escape_seq)), try ((optional $ char '\\') *> (eol)), (notFollowedBy (choice $ linebreak : (map (fromChar <$> char) "`\\$"))) *> source_char]
|
||||||
source_char = error "TODO"
|
source_char = error "TODO"
|
||||||
template_escape_seq = error "TODO: TemplateEscapeSequence, prepend backslash"
|
template_escape_seq = error "TODO: TemplateEscapeSequence, prepend backslash"
|
||||||
not_escape_seq = error "TODO: NotEscapeSequence, prepend backslash"
|
not_escape_seq = error "TODO: NotEscapeSequence, prepend backslash"
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,11 @@ class ToText t where
|
||||||
|
|
||||||
class ToChar c where
|
class ToChar c where
|
||||||
toChar :: c -> Char
|
toChar :: c -> Char
|
||||||
|
fromChar :: Char -> c
|
||||||
|
|
||||||
instance ToChar Char where
|
instance ToChar Char where
|
||||||
toChar = id
|
toChar = id
|
||||||
|
fromChar = id
|
||||||
|
|
||||||
instance Characters Text
|
instance Characters Text
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue