File: issue_141.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 (40 lines) | stat: -rw-r--r-- 716 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
{
-- Issue #141
-- reported 2015-10-20 by Iavor S. Diatchki
-- fixed 2020-01-31 by Andreas Abel
--
-- Problem was:
-- Only one-digit numbers were accepted in repetition ranges.

module Main (main) where

import System.Exit
}

%wrapper "posn"
%token   "Token"

:-

-- allow several digits in repetition ranges, e.g. 14
"a"{14,14}          { \ _ _ -> A }
[\ \n\t]+           ;

{
data Token = A
  deriving (Eq, Show)

                -- 12345678901234
input           = "aaaaaaaaaaaaaa\n"  -- fourteen a's
expected_result = [A]

main :: IO ()
main
  | result == expected_result = do
      exitWith ExitSuccess
  | otherwise = do
      print $ take 20 result
      exitFailure
  where
  result = alexScanTokens input
}