From 1cb17a85c421f01a009d7489114242e84a69a1d0 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 2 Apr 2009 15:36:42 +0000 Subject: [PATCH] Removed a lot of the junk from the lexer I'd recently added The lexer is now roughly as it was a couple of weeks ago. --- frontends/LexOccam.x | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/frontends/LexOccam.x b/frontends/LexOccam.x index f12a2bd..5c2a74d 100644 --- a/frontends/LexOccam.x +++ b/frontends/LexOccam.x @@ -100,19 +100,9 @@ occam :- -- In state one, we're reading the first thing on a line. -- In state two, we're reading the rest of the line. -- In state three, we're in the middle of a multi-line string. --- In state four, we're in the middle of a pragma-external string --- In state five, we're lexing a pragma. State five is only entered specifically, --- when we re-lex and re-parse pragmas (but it makes it easiest to put it --- in this file too, since it can lex occam). <0> $horizSpace* { mkState one } - "SHARED" { mkToken Pragma two } - "PERMITALIASES" { mkToken Pragma two } - "EXTERNAL" $horizSpace* \" { mkToken Pragma four } - "OCCAMEXTERNAL" $horizSpace* \" { mkToken Pragma four } - \" $horizSpace* { mkState 0 } - @preprocessor { mkToken TokPreprocessor 0 } "--" [^\n]* { mkState 0 } $vertSpace+ { mkState 0 } @@ -120,9 +110,6 @@ occam :- @reserved { mkToken TokReserved two } @identifier { mkToken TokIdentifier two } - @reserved { mkToken TokReserved four } - @identifier { mkToken TokIdentifier four } - @charLiteral { mkToken TokCharLiteral two } @fullString { mkToken TokStringLiteral two } @startString { mkToken TokStringCont three } @@ -135,11 +122,7 @@ occam :- @hexLiteral { mkToken TokHexLiteral two } @realLiteral { mkToken TokRealLiteral two } - @intLiteral { mkToken TokIntLiteral four } - @hexLiteral { mkToken TokHexLiteral four } - @realLiteral { mkToken TokRealLiteral four } - - $horizSpace+ ; + $horizSpace+ ; { -- | An occam source token and its position. @@ -221,29 +204,5 @@ runLexer filename str = go (alexStartPos, '\n', str) 0 metaColumn = col } --- | Run the lexer, returning a list of tokens. --- (This is based on the `alexScanTokens` function that Alex provides.) -runPragmaLexer :: String -> String -> Either (Maybe Meta, String) [Token] -runPragmaLexer filename str = go (alexStartPos, '\n', str) five - where - go inp@(pos@(AlexPn _ line col), _, str) code = - case alexScan inp code of - AlexEOF -> return [] - AlexError _ -> throwError (Just meta, "Unrecognised token") - AlexSkip inp' len -> go inp' code - AlexToken inp' len act -> - do let (t, code) = act pos (take len str) - ts <- go inp' code - return $ case t of - Just (Token _ tt) -> Token meta tt : ts - Nothing -> ts - - where - meta = emptyMeta { - metaFile = Just filename, - metaLine = line, - metaColumn = col - } - }