File: issue_197.x

package info (click to toggle)
alex 3.4.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 768 kB
  • sloc: haskell: 4,648; makefile: 138; yacc: 56; ansic: 4
file content (43 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
}