blob: 47f40b7dec79cb674bb9f155b2a8fe4a267d8317 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
%{
%}
/* Only multiline comments are supported, not comments that start with // */
/* This is a definition, it's in the format "NAME regex" */
DIGIT [0-9]
%%
/* Comments in here have to be indented, otherwise you'll get an error */
/* ? means 0 or 1 of the preceding group */
/* + means 1 or more of the preceding group */
/* the backward slashes are used because . and + have special meaning in regexes */
[\+-]?{DIGIT}+(\.{DIGIT}+)? { printf("<span class=\"num\">%s</span>", yytext); }
/* [^] is a group of characters, like [], however it specifies "all characters except the ones given" */
/* this way if we have "This is a string with " three quotes" it's not going to match the whole thing */
\"[^"]*\"|'[^']*' { printf("<span class=\"str\">%s</span>", yytext); }
%%
|