UbcLanguage Definition

This commit is contained in:
VegOwOtenks 2024-12-30 08:44:51 +01:00
parent e494aaff06
commit f1599d6860
3 changed files with 55 additions and 0 deletions

9
app/Main.hs Normal file
View file

@ -0,0 +1,9 @@
module Main (main) where
import Data.Text.Ubc.Parse
main :: IO ()
main = do
text <- getContents
someFunc
return ()

View file

@ -0,0 +1,5 @@
module Data.String.Ubc.Parse
( someFunc )
where
someFunc = putStrLn "help"

View 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