Commit 00dd05e4 authored by agibiansky's avatar agibiansky Committed by Austin Seipp
Browse files

Adding more parser exports and some documentation.

Summary: Add a few exports to be generated by the Happy parser module. Add documentation showing how to use the Happy parser.

Test Plan: Validate

Reviewers: carter, austin

Reviewed By: austin

Subscribers: phaskell, simonmar, relrod, carter

Differential Revision: https://phabricator.haskell.org/D71
parent 18b2c467
......@@ -16,8 +16,25 @@
-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
-- for details
module Parser ( parseModule, parseStmt, parseIdentifier, parseType,
parseHeader ) where
-- | This module provides the generated Happy parser for Haskell. It exports
-- a number of parsers which may be used in any library that uses the GHC API.
-- A common usage pattern is to initialize the parser state with a given string
-- and then parse that string:
--
-- @
-- runParser :: DynFlags -> String -> P a -> ParseResult a
-- runParser flags str parser = unP parser parseState
-- where
-- filename = "\<interactive\>"
-- location = mkRealSrcLoc (mkFastString filename) 1 1
-- buffer = stringToStringBuffer str
-- parseState = mkPState flags buffer location in
-- @
module Parser (parseModule, parseImport, parseStatement,
parseDeclaration, parseExpression, parseTypeSignature,
parseFullStmt, parseStmt, parseIdentifier,
parseType, parseHeader) where
import HsSyn
import RdrHsSyn
......@@ -363,12 +380,20 @@ TH_QQUASIQUOTE { L _ (ITqQuasiQuote _) }
%monad { P } { >>= } { return }
%lexer { lexer } { L _ ITeof }
%tokentype { (Located Token) }
-- Exported parsers
%name parseModule module
%name parseImport importdecl
%name parseStatement stmt
%name parseDeclaration topdecl
%name parseExpression exp
%name parseTypeSignature sigdecl
%name parseFullStmt stmt
%name parseStmt maybe_stmt
%name parseIdentifier identifier
%name parseType ctype
%partial parseHeader header
%tokentype { (Located Token) }
%%
-----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment