forked from GitHub/gf-core
Make first letter in GSL category names upper case.
This commit is contained in:
@@ -28,6 +28,8 @@ import GrammarTypes
|
|||||||
import PrintParser
|
import PrintParser
|
||||||
import Option
|
import Option
|
||||||
|
|
||||||
|
import Data.Char (toUpper)
|
||||||
|
|
||||||
gslPrinter :: Ident -- ^ Grammar name
|
gslPrinter :: Ident -- ^ Grammar name
|
||||||
-> Options -> CFGrammar -> String
|
-> Options -> CFGrammar -> String
|
||||||
gslPrinter name opts cfg = prGSL srg ""
|
gslPrinter name opts cfg = prGSL srg ""
|
||||||
@@ -49,7 +51,12 @@ prGSL (SRG{grammarName=name,startCat=start,origStartCat=origStart,rules=rs})
|
|||||||
where rhs' = rmPunct rhs
|
where rhs' = rmPunct rhs
|
||||||
prSymbol (Cat c) = prCat c
|
prSymbol (Cat c) = prCat c
|
||||||
prSymbol (Tok t) = wrap "\"" (prtS t) "\""
|
prSymbol (Tok t) = wrap "\"" (prtS t) "\""
|
||||||
prCat c = showString c
|
-- GSL requires an upper case letter in category names
|
||||||
|
prCat c = showString (firstToUpper c)
|
||||||
|
|
||||||
|
firstToUpper :: String -> String
|
||||||
|
firstToUpper [] = []
|
||||||
|
firstToUpper (x:xs) = toUpper x : xs
|
||||||
|
|
||||||
rmPunct :: [Symbol String Token] -> [Symbol String Token]
|
rmPunct :: [Symbol String Token] -> [Symbol String Token]
|
||||||
rmPunct [] = []
|
rmPunct [] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user