-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#202) In issue #141, multiplicity annotations in regexes where extended to the general, multi-digit case {nnn,mmm}. However, lexing numeric literals broke parsing of regexes like: 32|64 [01-89] The solution here is to only lex numeric literals in a special lexer state called `multiplicity` which is entered by the parser when parsing multiplicity braces {nnn,mmm}. This restores alex' handling of digits as characters in the non-multiplicity situations.
- Loading branch information
1 parent
e4843f2
commit e907ecb
Showing
5 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
-- Issue #197 | ||
-- reported 2022-01-21 by https://github.com/Commelina | ||
-- fixed 2022-01-23 by Andreas Abel & John Ericson | ||
-- | ||
-- Problem was: | ||
-- Surface syntax regressed and could no longer handle character strings | ||
-- that looked like numbers. | ||
|
||
module Main (main) where | ||
|
||
import System.Exit | ||
} | ||
|
||
%wrapper "posn" | ||
%token "Token" | ||
|
||
@iec60559suffix = (32|64|128)[x]? | ||
@any = [01-89]+[x]? | ||
|
||
:- | ||
|
||
$white+ ; | ||
@iec60559suffix { \ _ -> Good } | ||
@any { \ _ -> Bad } | ||
|
||
{ | ||
data Token = Good String | Bad String | ||
deriving (Eq, Show) | ||
|
||
input = "32 32x 99 99x 128x" | ||
expected_result = [Good "32", Good "32x", Bad "99", Bad "99x", Good "128x"] | ||
|
||
main :: IO () | ||
main | ||
| result == expected_result = do | ||
exitWith ExitSuccess | ||
| otherwise = do | ||
print result | ||
exitFailure | ||
where | ||
result = alexScanTokens input | ||
} |