File: romanlexer.l

package info (click to toggle)
postgresql-numeral 1.3-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 196 kB
  • sloc: ansic: 370; yacc: 242; sql: 194; lex: 169; makefile: 37; sh: 19
file content (46 lines) | stat: -rw-r--r-- 1,125 bytes parent folder | download | duplicates (5)
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
/*
Copyright (C) 2017 Christoph Berg

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
*/

%{
#include "numeral.h"
#include "romanparser.tab.h"
%}

%option prefix="yyroman"
%option noyywrap
%option nounput
%option noinput

INT_R [\-+]?[0-9]+

%%

{INT_R} {
	yyromanlval = atoll(yytext);
	return INT;
}

nulla { yyromanlval = 0; return ZERO; }
minus { yyromanlval = -1; return MINUS; }
[iI]  { yyromanlval = 1; return I; }
[vV]  { yyromanlval = 5; return V; }
[xX]  { yyromanlval = 10; return X; }
[lL]  { yyromanlval = 50; return L; }
[cC]  { yyromanlval = 100; return C; }
[dD]  { yyromanlval = 500; return D; }
[mM]  { yyromanlval = 1000; return M; }

[ \t\n]* /* eat whitespace */

. return ERR;