-
Notifications
You must be signed in to change notification settings - Fork 200
/
Srmc.x
126 lines (98 loc) · 3.09 KB
/
Srmc.x
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
-- -*- haskell -*-
--
-- Simple syntax highlighting for srmc source.
-- Also to be used for pepa source files since pepa
-- is a subset of srmc.
-- I also believe that this makes a reasonable example
-- for new syntax files
--
{
{-# OPTIONS -w #-}
module Yi.Lexer.Srmc ( initState, alexScanToken ) where
{- Local Modules Imported -}
import Yi.Lexer.Alex
import qualified Yi.Syntax
import Yi.Style
( Style ( .. )
, defaultStyle
, commentStyle
, blockCommentStyle
, keywordStyle
, operatorStyle
, typeStyle
, stringStyle
, numberStyle
, StyleName
)
{- End of Module Imports -}
}
$whitechar = [\ \t\n\r\f\v]
$special = [\(\)\,\;\[\]\`\{\}]
$ascdigit = 0-9
$unidigit = [] -- TODO
$digit = [$ascdigit $unidigit]
$ascsymbol = [\!\#\$\%\&\*\+\.\/\<\=\>\?\@\\\^\|\-\~]
$unisymbol = [] -- TODO
$pepasymbol = [\;\.\,\+=\<\>]
$symbol = [$pepasymbol]
$large = [A-Z \xc0-\xd6 \xd8-\xde]
$small = [a-z \xdf-\xf6 \xf8-\xff \_]
$alpha = [$small $large]
$graphic = [$small $large $symbol $digit $special \:\"\']
$octit = 0-7
$hexit = [0-9 A-F a-f]
$idchar = [$alpha $digit \']
$symchar = [$symbol]
$nl = [\n\r]
@reservedid = Stop|infty
@reservedop = "&&" | "||"
@varid = $small $idchar*
@conid = $large $idchar*
@varsym = $symbol $symchar*
@consym = \: $symchar*
@decimal = $digit+
@double = $digit+ \. $digit+
@octal = $octit+
@hexadecimal = $hexit+
@exponent = [eE] [\-\+] @decimal
$cntrl = [$large \@\[\\\]\^\_]
@ascii = \^ $cntrl | NUL | SOH | STX | ETX | EOT | ENQ | ACK
| BEL | BS | HT | LF | VT | FF | CR | SO | SI | DLE
| DC1 | DC2 | DC3 | DC4 | NAK | SYN | ETB | CAN | EM
| SUB | ESC | FS | GS | RS | US | SP | DEL
$charesc = [abfnrtv\\\"\'\&]
@escape = \\ ($charesc | @ascii | @decimal | o @octal | x @hexadecimal)
@gap = \\ $whitechar+ \\
@string = $graphic # [\"\\] | " " | @escape | @gap
haskell :-
<0> $white+ { c defaultStyle } -- whitespace
<0> {
"%"\-*[^\n]* { c commentStyle }
"//"\-*[^\n]* { c commentStyle }
-- $special { c defaultStyle }
@reservedid { c keywordStyle }
@varid { c stringStyle }
@conid { c typeStyle }
@reservedop { c operatorStyle }
@varsym { c operatorStyle }
@decimal
| @double
| 0[oO] @octal
| 0[xX] @hexadecimal { c numberStyle }
@decimal \. @decimal @exponent?
| @decimal @exponent { c defaultStyle }
. { c defaultStyle }
\" @string* \" { c keywordStyle }
}
{
type HlState = Int
type Token = StyleName
{-
See Haskell.x which uses this to say whether we are in a
comment (perhaps a nested comment) or not.
-}
stateToInit x = 0
initState :: HlState
initState = 0
#include "common.hsinc"
}