on master help sign in
Add iParse that takes a table
commitf1a88975d2d14df302eb141a11400886e199afe1 authorEvan Czaplicki <info@elm-lang.org> dateThu 29 Aug 2013, 00:55 (13 years ago) parent6d27c5e
3 files changed+8−5
compiler/Parse/Helpers.hs+6−3 compiler/Parse/Module.hs+1−1 compiler/Parse/Parse.hs+1−1
compiler/Parse/Helpers.hs+6−3
@@ -41,9 +41,12 @@ type OpTable = Map.Map String (Int, Assoc)
4141
4242type IParser a = ParsecT String OpTable (State SourcePos) a
4343
44−iParse :: IParser a -> SourceName -> String -> Either ParseError a
45−iParse aParser source_name input =
46− runIndent source_name $ runParserT aParser () source_name input
44+iParse :: IParser a -> String -> Either ParseError a
45+iParse = iParseWithTable "" Map.empty
46+
47+iParseWithTable :: SourceName -> OpTable -> IParser a -> String -> Either ParseError a
48+iParseWithTable sourceName table aParser input =
49+ runIndent sourceName $ runParserT aParser table sourceName input
4750
4851backslashed :: IParser Char
4952backslashed = do { char '\\'; c <- anyChar
compiler/Parse/Module.hs+1−1
@@ -13,7 +13,7 @@ varList = parens $ commaSep1 (var <|> parens symOp)
1313
1414getModuleName :: String -> Maybe String
1515getModuleName source =
16− case iParse getModuleName "" source of
16+ case iParse getModuleName source of
1717 Right name -> Just name
1818 Left _ -> Nothing
1919 where
compiler/Parse/Parse.hs+1−1
@@ -42,6 +42,6 @@ dependencies =
4242
4343setupParser :: IParser a -> String -> Either [P.Doc] a
4444setupParser p source =
45− case iParse p "" source of
45+ case iParse p source of
4646 Right result -> Right result
4747 Left err -> Left [ P.text $ "Parse error at " ++ show err ]