- newtype CommonToken = CommonToken (Ptr CommonToken)
- newtype InputStream = InputStream (Ptr InputStream)
- newtype Lexer = Lexer (Ptr Lexer)
- toInputStream :: Ptr InputStream -> InputStream
- toCommonToken :: Ptr CommonToken -> CommonToken
- fromCommonToken :: CommonToken -> Ptr b
- lT :: Ptr InputStream -> Int -> IO (Ptr CommonToken)
- newtype AntlrString = AntlrString (Ptr AntlrString)
- fromAntlrString :: AntlrString -> Ptr b
- tokenGetAntlrString :: Ptr CommonToken -> IO (Ptr AntlrString)
- fromAntlrStringToMaybeString :: AntlrString -> IO (Maybe String)
- tokenGetTextMaybe :: Ptr CommonToken -> IO (Maybe String)
- fromAntlrStringToString :: AntlrString -> IO String
- tokenGetText :: Ptr CommonToken -> IO String
- tokenGetType :: Enum e => Ptr CommonToken -> IO e
- tokenGetCharPositionInLine :: Ptr CommonToken -> IO Int
- tokenGetLine :: Ptr CommonToken -> IO Int
- lT'_ :: InputStream -> CInt -> IO CommonToken
- tokenGetAntlrString'_ :: CommonToken -> IO AntlrString
Documentation
toInputStream :: Ptr InputStream -> InputStreamSource
Cast from a pointer to an input stream to an input stream.
toCommonToken :: Ptr CommonToken -> CommonTokenSource
Cast from a pointer to a token to a token.
fromCommonToken :: CommonToken -> Ptr bSource
Cast from a token to a pointer to a token.
lT :: Ptr InputStream -> Int -> IO (Ptr CommonToken)Source
Lookahead in the input stream at the token at the specified positive offset, where:
LT input 1
is the current token. Or a negative offset may be specified, where:
LT input (-1)
is the previous token.
foreign export ccall isUnsignedInt :: Ptr InputStream -> IO Bool isUnsignedInt input = do token1 <- lT input 1 >>= tokenGetType if token1 /= UNSIGNED then return False else do token2 <- lT input 2 >>= tokenGetType return ((token2 /= CHAR) && (token2 /= SHORT) && (token2 /= LONG))
fromAntlrString :: AntlrString -> Ptr bSource
Cast from an ANTLR string to a pointer to an ANTLR string.
tokenGetAntlrString :: Ptr CommonToken -> IO (Ptr AntlrString)Source
Obtain the token name ANTLR string for the specified token.
tokenGetAntlrString token
For identifier tokens, the token string is interesting. For other tokens such as operator tokens, the token string is uninteresting, and may not be present, the token identifier enum should be used instead.
fromAntlrStringToMaybeString :: AntlrString -> IO (Maybe String)Source
Convert an ANTLR string to a Maybe String.
tokenGetTextMaybe :: Ptr CommonToken -> IO (Maybe String)Source
Obtain the token Maybe String for the specified token. For identifier tokens, the token string is interesting. For other tokens such as operator tokens, the token string is uninteresting, and may not be present, the token identifier enum should be used instead.
fromAntlrStringToString :: AntlrString -> IO StringSource
Convert from an ANTLR string to a String. Note: the peekCStringLen function does not say what will happen if the C pointer is 0.
tokenGetText :: Ptr CommonToken -> IO StringSource
Obtain the token String for the specified token. Note: the peekCStringLen function does not say what will happen if the C pointer is 0.
foreign export ccall saIntV :: Ptr CommonToken -> IO (StablePtr TermInfo) saIntV token = do -- read the IntV integer value from the token text into n t <- tokenGetText token n <- readIO t -- obtain the source code line and charPosition from the token l <- tokenGetLine token c <- tokenGetCharPositionInLine token -- return the term, which is TmZero, or TmSucc TmZero, or TmSucc (TmSucc (...TmSucc TmZero)) newStablePtr (intV (Info l c) n)
tokenGetType :: Enum e => Ptr CommonToken -> IO eSource
Obtain the token identifier for the specified token.
foreign export ccall isInt :: Ptr InputStream -> IO Bool isInt input = do token1 <- lT input 1 >>= tokenGetType return (token1 == INT)
tokenGetCharPositionInLine :: Ptr CommonToken -> IO IntSource
Obtain the character position in the source code line of where the token was read, for non-imaginary tokens.
foreign export ccall saTrue :: Ptr CommonToken -> IO (StablePtr TermInfo) saTrue token = do -- obtain the source code line and charPosition from the token l <- tokenGetLine token c <- tokenGetCharPositionInLine token -- return the TmTrue term newStablePtr (TmTrue (Info l c))
tokenGetLine :: Ptr CommonToken -> IO IntSource
Obtain the the source code line of where the token was read, for non-imaginary tokens.
foreign export ccall saFalse :: Ptr CommonToken -> IO (StablePtr TermInfo) saFalse token = do -- obtain the source code line and charPosition from the token l <- tokenGetLine token c <- tokenGetCharPositionInLine token -- return the TmFalse term newStablePtr (TmFalse (Info l c))
lT'_ :: InputStream -> CInt -> IO CommonTokenSource