-
Notifications
You must be signed in to change notification settings - Fork 0
/
logo_lexique.gLexique
103 lines (78 loc) · 3.47 KB
/
logo_lexique.gLexique
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
lexique logo_lexique :
#----------------------------------------------------------------------------*
# Identifiers and keywords *
#----------------------------------------------------------------------------*
@string tokenString ;
style keywordsStyle -> "Keywords" ;
$identifier$ ! tokenString error message "an identifier" ;
#--- This is the keyword list
list keyWordList error message "the '%K' keyword" style keywordsStyle :
"PROGRAM", "ROUTINE", "BEGIN", "END", "FORWARD", "ROTATE", "PEN", "UP", "DOWN", "CALL"
;
rule 'a'->'z' | 'A'->'Z' :
repeat
enterCharacterIntoString !?tokenString !* ;
while 'a'->'z' | 'A'->'Z' :
end repeat ;
send search tokenString in keyWordList default $identifier$ ;
end rule ;
#----------------------------------------------------------------------------*
# Literal decimal integers *
#----------------------------------------------------------------------------*
style integerStyle -> "Integer Constants" ;
@uint uint32value ;
$integer$ !uint32value error message "a 32-bit unsigned decimal number" style integerStyle ;
message decimalNumberTooLarge : "decimal number too large" ;
message internalError : "internal error" ;
rule '0'->'9' :
enterCharacterIntoString !?tokenString !* ;
repeat
while '0'->'9' :
enterCharacterIntoString !?tokenString !* ;
end repeat ;
convertDecimalStringIntoUInt !tokenString !?uint32value error decimalNumberTooLarge, internalError ;
send $integer$ ;
end rule ;
#----------------------------------------------------------------------------*
# Litteral character strings *
#----------------------------------------------------------------------------*
style stringStyle -> "String Constants" ;
$literal_string$ ! tokenString error message "a character string constant \"...\"" style stringStyle feature nonAtomicSelection ;
message incorrectStringEnd : "string does not end with '\"'" ;
rule '"' :
repeat
while ' ' | '!' | '#'-> '\uFFFD' :
enterCharacterIntoString !?tokenString !* ;
end repeat ;
select
when '"' :
send $literal_string$ ;
default
error incorrectStringEnd ;
end select ;
end rule ;
#----------------------------------------------------------------------------*
# Delimiters *
#----------------------------------------------------------------------------*
style delimitersStyle -> "Delimiters" ;
list delimitorsList error message "the '%K' delimitor" style delimitersStyle :
";", "." ;
rule list delimitorsList ;
#----------------------------------------------------------------------------*
# Comments *
#----------------------------------------------------------------------------*
style commentStyle -> "Comments" ;
$comment$ error message "a comment" style commentStyle feature nonAtomicSelection ;
rule '#' :
repeat
while '\u0001' -> '\u0009' | '\u000B' | '\u000C' | '\u000E' -> '\uFFFD' :
end repeat ;
drop $comment$ ;
end rule ;
#----------------------------------------------------------------------------*
# Separators *
#----------------------------------------------------------------------------*
rule '\u0001' -> ' ' :
end rule ;
#----------------------------------------------------------------------------*
end lexique ;