module BNFC.Backend.Java.Utils where
import BNFC.CF
import BNFC.Utils ( mkName, NameStyle(..))
import BNFC.Backend.Common.NamedVariables
comment :: String -> String
= (String
"// " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
javaReserved :: [String]
javaReserved :: [String]
javaReserved =
[ String
"abstract"
, String
"assert"
, String
"boolean"
, String
"break"
, String
"byte"
, String
"case"
, String
"catch"
, String
"char"
, String
"class"
, String
"const"
, String
"continue"
, String
"default"
, String
"do"
, String
"double"
, String
"else"
, String
"enum"
, String
"extends"
, String
"false"
, String
"final"
, String
"finally"
, String
"float"
, String
"for"
, String
"goto"
, String
"if"
, String
"implements"
, String
"import"
, String
"instanceof"
, String
"int"
, String
"interface"
, String
"long"
, String
"native"
, String
"new"
, String
"null"
, String
"package"
, String
"private"
, String
"protected"
, String
"public"
, String
"return"
, String
"short"
, String
"static"
, String
"strictfp"
, String
"super"
, String
"switch"
, String
"synchronized"
, String
"true"
, String
"this"
, String
"throw"
, String
"throws"
, String
"transient"
, String
"try"
, String
"void"
, String
"volatile"
, String
"while"
]
getRuleName :: String -> String
getRuleName :: String -> String
getRuleName String
z
| String -> String
firstLowerCase String
z String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (String
"grammar" String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
javaReserved) = String
z String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_"
| Bool
otherwise = String
z
getLabelName :: Fun -> String
getLabelName :: String -> String
getLabelName = [String] -> NameStyle -> String -> String
mkName [String
"Rule"] NameStyle
CamelCase
getLastInPackage :: String -> String
getLastInPackage :: String -> String
getLastInPackage =
[String] -> String
forall a. [a] -> a
last ([String] -> String) -> (String -> [String]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words (String -> [String]) -> (String -> String) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map (\Char
c -> if Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'.' then Char
' ' else Char
c)
startSymbol :: String -> String
startSymbol :: String -> String
startSymbol = (String
"Start_" String -> String -> String
forall a. [a] -> [a] -> [a]
++)