UbcLanguage Definition
This commit is contained in:
parent
e494aaff06
commit
f1599d6860
3 changed files with 55 additions and 0 deletions
9
app/Main.hs
Normal file
9
app/Main.hs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module Main (main) where
|
||||||
|
|
||||||
|
import Data.Text.Ubc.Parse
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
text <- getContents
|
||||||
|
someFunc
|
||||||
|
return ()
|
5
src/Data/String/Ubc/Parse.hs
Normal file
5
src/Data/String/Ubc/Parse.hs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module Data.String.Ubc.Parse
|
||||||
|
( someFunc )
|
||||||
|
where
|
||||||
|
|
||||||
|
someFunc = putStrLn "help"
|
41
src/Data/String/Ubc/Parse/Language.hs
Normal file
41
src/Data/String/Ubc/Parse/Language.hs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
module Data.String.Ubc.Parse.Language
|
||||||
|
( languageDef
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Text.Parsec
|
||||||
|
import Text.Parsec.Token
|
||||||
|
import Text.Parsec.Language
|
||||||
|
|
||||||
|
languageDef :: GenLanguageDef String u m
|
||||||
|
languageDef = LanguageDef {
|
||||||
|
commentStart = "/*"
|
||||||
|
, commentEnd = "*/"
|
||||||
|
, commentLine = "//"
|
||||||
|
, nestedComments = True
|
||||||
|
, identStart = letter <|> char '_'
|
||||||
|
, identLetter = alphaNum <|> char '_'
|
||||||
|
, opStart = oneOf "+-*/"
|
||||||
|
, opLetter = oneOf "+-*/"
|
||||||
|
, reservedNames = [ "struct", "u32", "i32", "f32" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenParser :: GenTokenParser String u m
|
||||||
|
tokenParser = makeTokenParser languageDef
|
||||||
|
|
||||||
|
TokenParser{
|
||||||
|
identifier = identifier
|
||||||
|
, reserved = reserved
|
||||||
|
, operator = operator
|
||||||
|
, reservedOp = reservedOperator
|
||||||
|
, charLiteral = characterLiteral
|
||||||
|
, stringLiteral = stringLiteral
|
||||||
|
, natural = natural -- decimal, hexadecimal or octal
|
||||||
|
, integer = integer -- decimal, hexadecimal or octal
|
||||||
|
, float = float
|
||||||
|
, naturalOrFloat = naturalOrFloat
|
||||||
|
, decimal = decimal
|
||||||
|
, hexadecimal = hexadecimal
|
||||||
|
, octal = octal
|
||||||
|
, symbol = symbol
|
||||||
|
} = tokenParser
|
Loading…
Reference in a new issue