File: special_escapes.hs

package info (click to toggle)
re2c 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 50,052 kB
  • sloc: cpp: 32,477; ml: 8,279; sh: 5,265; makefile: 968; haskell: 612; python: 428; ansic: 227; javascript: 111; java: 3
file content (149 lines) | stat: -rw-r--r-- 3,551 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
-- Generated by re2hs
{-# LANGUAGE RecordWildCards #-}
-- re2hs $INPUT -o $OUTPUT -i
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-unused-record-wildcards #-}

import Data.ByteString (ByteString, index)

data State = State {
    _yyinput :: ByteString,
    _yycursor :: Int,
    _yymarker :: Int
}


yy0 :: State -> Bool
yy0 State{..} =
    let yych = index _yyinput _yycursor in
    let __ = _yycursor + 1 in let _yycursor = __ in
    case yych of
        _c | 0x07 == _c ->
            yy3 State{..}
        _c | True ->
            yy1 State{..}

yy1 :: State -> Bool
yy1 State{..} =
    yy2 State{..}

yy2 :: State -> Bool
yy2 State{..} =
    let _ = ['\a', '\b', '\f', '\n', '\r', '\t', '\v', '\\', '\'', '\"'] in
    False

yy3 :: State -> Bool
yy3 State{..} =
    let _yymarker = _yycursor in
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x08 == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy4 State{..}
        _c | True ->
            yy2 State{..}

yy4 :: State -> Bool
yy4 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x0C == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy6 State{..}
        _c | True ->
            yy5 State{..}

yy5 :: State -> Bool
yy5 State{..} =
    let _yycursor = _yymarker in
    yy2 State{..}

yy6 :: State -> Bool
yy6 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x0A == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy7 State{..}
        _c | True ->
            yy5 State{..}

yy7 :: State -> Bool
yy7 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x0D == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy8 State{..}
        _c | True ->
            yy5 State{..}

yy8 :: State -> Bool
yy8 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x09 == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy9 State{..}
        _c | True ->
            yy5 State{..}

yy9 :: State -> Bool
yy9 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x0B == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy10 State{..}
        _c | True ->
            yy5 State{..}

yy10 :: State -> Bool
yy10 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x5C == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy11 State{..}
        _c | True ->
            yy5 State{..}

yy11 :: State -> Bool
yy11 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x27 == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy12 State{..}
        _c | True ->
            yy5 State{..}

yy12 :: State -> Bool
yy12 State{..} =
    let yych = index _yyinput _yycursor in
    case yych of
        _c | 0x22 == _c ->
            let __ = _yycursor + 1 in let _yycursor = __ in
            yy13 State{..}
        _c | True ->
            yy5 State{..}

yy13 :: State -> Bool
yy13 State{..} =
    True

lexer :: State -> Bool
lexer State{..} =
    yy0 State{..}



main :: IO ()
main = do
    let st = State{
            _yyinput = "\x07\x08\x0c\x0a\x0d\x09\x0b\\'\"\0",
            _yycursor = 0,
            _yymarker = 0}
    case lexer st of
        True -> return ()
        False -> error "lexer failed!"