File: standalone_single_quotes.re

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 (25 lines) | stat: -rw-r--r-- 696 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
-- re2hs $INPUT -o $OUTPUT -i
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-unused-record-wildcards #-}

import Data.ByteString (ByteString, index)

data S't''a'''t'e' = S't''a'''t'e' {
    _yyinput :: ByteString,
    _yycursor :: Int
}

%{
    re2c:define:YYFN = ["l'''e'x''''e'r';Bool", "S't''a'''t'e'{..};S't''a'''t'e'"];
    re2c:yyfill:enable = 0;

    number = [1-9][0-9]*;

    number { let _x' = '}' in let _x'' = '}' in let x'0'' = True in x'0'' }
    *      { let _y' = '\n' in let _x'' = '\'' in let y' = False in y' }
%}

main :: IO ()
main = case l'''e'x''''e'r' S't''a'''t'e'{_yyinput = "1234\0", _yycursor = 0} of
    True -> return ()
    False -> error "lexer failed!"