webidl 0.1 → 0.1.1
raw patch · 4 files changed
+25/−8 lines, 4 filesdep −cpphsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: cpphs
API changes (from Hackage documentation)
- Language.WebIDL.Syntax: IDLScopedName :: [String] -> IDLScopedName
+ Language.WebIDL.Syntax: IDLScopedName :: Bool -> [String] -> IDLScopedName
Files
- Language/WebIDL/Parser.hs +14/−4
- Language/WebIDL/PrettyPrint.hs +4/−1
- Language/WebIDL/Syntax.hs +1/−1
- webidl.cabal +6/−2
Language/WebIDL/Parser.hs view
@@ -123,7 +123,7 @@ value_dcl = do tokVALUETYPE- vi <- tokIDENTIFIER >>= return . name+ vi <- id_or_domstring mt <- option Nothing (try type_spec >>= return . Just) return $ IDLDefValue vi mt @@ -212,8 +212,9 @@ return $ sus it scoped_name = do- ns <- (tokIDENTIFIER >>= return . name) `sepBy1` tokOP_SCOPE- return $ IDLScopedName ns+ outer <- option False (try tokOP_SCOPE >> return True)+ ns <- id_or_domstring `sepBy1` tokOP_SCOPE+ return $ IDLScopedName outer ns extended_attribute_list = brackets (extended_attribute `sepBy1` tokComma) @@ -350,7 +351,16 @@ try (tokFALSE >> return (IDLBoolLit "FALSE")) <?> "literal" -simple_declarator = tokIDENTIFIER >>= return . name+simple_declarator = id_or_domstring++-- There is one marginal case when DOMString acts as a declarator.+-- This results in the tokSTRING to occur in the place of the declarator.+-- The following code takes care of that, so "typedef dom::DOMString DOMString"+-- does not crash the parser.++id_or_domstring =+ try (tokSTRING >> return "DOMString") <|>+ try (tokIDENTIFIER >>= return . name) -- Preprocessor directives: ignore everything between pound-sign and EOL. -- Sometimes the last line contains #endif, and then EOF without EOL.
Language/WebIDL/PrettyPrint.hs view
@@ -51,7 +51,10 @@ prInhr [] = empty prInhr sns = colon <+> hsep (punctuate comma (map prScoped sns)) -prScoped (IDLScopedName ns) = hsep $ punctuate (space <> colon <> colon) (map text ns)+prScoped (IDLScopedName outer ns) = + let dcolon =space <> colon <> colon+ oc = if outer then [dcolon] else []+ in hsep $ oc ++ punctuate dcolon (map text ns) prIbody (IDLInterfaceBody exps) = vcat (map prExport exps)
Language/WebIDL/Syntax.hs view
@@ -76,7 +76,7 @@ -- | OP_SCOPE IDENTIFIER -- | scoped_name OP_SCOPE IDENTIFIER -data IDLScopedName = IDLScopedName [String] deriving (Show)+data IDLScopedName = IDLScopedName Bool [String] deriving (Show) -- extended_attribute_opt : -- | extended_attribute_list
webidl.cabal view
@@ -1,5 +1,5 @@ Name: webidl-Version: 0.1+Version: 0.1.1 Author: Dmitry Golubovsky Maintainer: Dmitry Golubovsky <golubovsky@gmail.com> License: BSD3@@ -33,11 +33,15 @@ The program may be used to test the parser and pretty printer in the way that when @idlppr@ reads a pretty-printed Web IDL source, the output should be identical to the input. + .+ Changes from 1.1: the parser has been fixed to recognize outermost-declared+ scoped names (those starting with "::"), and allow for use of @DOMString@+ in typedefs and valuetypes, as the Web IDL working draft prescribes. Build-Type: Custom Build-Depends: base >= 4.0.0 && < 5.0, utf8-env, utf8-string, - cpphs, bytestring >= 0.9, LEXER, HSFFIG >= 1.1, + bytestring >= 0.9, LEXER, HSFFIG >= 1.1, parsec >= 2.0 && < 3.0, pretty >= 1.0 Extra-source-files: cbits/lexer.ll include/esidl.h include/lexer.h include/parser.h cbits/Makefile