-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiralang.l
140 lines (111 loc) · 2.26 KB
/
miralang.l
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
%{
/* This file is part of the software similarity tester SIM.
Written by Dick Grune, Vrije Universiteit, Amsterdam.
$Id: miralang.l,v 1.17 2017-12-11 14:12:35 dick Exp $
*/
/*
Miranda language front end for the similarity tester.
Author: Emma Norling ([email protected])
Date: Nov 1998
*/
#include "token.h"
#include "properties.h"
#include "lex.h"
#include "lang.h"
/* General language front end data */
Token lex_token;
size_t lex_nl_cnt;
size_t lex_tk_cnt;
size_t lex_non_ASCII_cnt;
/* Language-dependent data */
#include "idf.h"
static const struct idf reserved[] = {
{"abstype", NORM('a')},
{"bool", NORM('b')},
{"char", NORM('c')},
{"const", META('c')},
{"div", NORM('d')},
{"False", NORM('F')},
{"if", NORM('i')},
{"mod", NORM('m')},
{"num", NORM('n')},
{"otherwise", NORM('o')},
{"readvals", NORM('r')},
{"show", NORM('s')},
{"sys_message", META('s')},
{"True", NORM('T')},
{"type", NORM('t')},
{"where", NORM('w')},
{"with", META('w')}
};
/* Token sets for properties module */
const Token Non_Finals[] = {
NORM('('),
NORM('['),
NORM('='),
No_Token
};
const Token Non_Initials[] = {
NORM(')'),
NORM(']'),
No_Token
};
const Token Openers[] = {
NORM('('),
NORM('['),
NORM('='),
No_Token
};
const Token Closers[] = {
NORM(')'),
NORM(']'),
No_Token
};
/* Language-dependent code */
const char *Subject = "Miranda programs";
void
Init_Language(void) {
Init_Language_Properties(Non_Finals, Non_Initials, Openers, Closers);
}
%}
%option noyywrap
%Start Comment
Layout ([ \t\r\f])
ASCII95 ([\040-\176])
AnyQuoted (\\.)
StrChar ([^\"\n\\]|{AnyQuoted})
ChrChar ([^\'\\]|{AnyQuoted})
Idf ([A-Za-z][A-Za-z0-9_\']*)
%%
"||".*$ { /* comment */
}
\"{StrChar}*\" { /* strings */
return_ch(STR);
}
\'{ChrChar}\' { /* characters */
return_ch('\'');
}
\%{Layout}*include.* { /* skip %include line */
}
\%{Layout}*insert.* { /* skip %insert line */
}
{Idf} { /* identifier */
return_tk(idf_in_list(yytext, reserved, sizeof reserved, IDF));
}
\n { /* count newlines */
return_eol();
}
{Layout} { /* ignore layout */
}
{ASCII95} { /* copy other text */
return_ch(yytext[0]);
}
. { /* count non-ASCII chars */
lex_non_ASCII_cnt++;
}
%%
/* More language-dependent code */
void
yystart(void) {
BEGIN INITIAL;
}