summaryrefslogtreecommitdiffstats
path: root/tksao/magnifier/lex.L
blob: 05c586d5dcd01ef6f3cc0100ae586f026128b90f (plain)
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
/* Copyright (C) 1999-2016
 * Smithsonian Astrophysical Observatory, Cambridge, MA, USA
 * For conditions of distribution and use, see copyright notice in "copyright"
 */

%option noyywrap
%option caseless
%option never-interactive
%option c++

%{
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>

  #include "parser.H"

  extern YYSTYPE* mglval;
%}

D   [0-9]
E   [Ee][+-]?{D}+

/* rules */

%%

bbox		{return BBOX_;}
clear		{return CLEAR_;}
debug		{return DEBUG_;}
false		{return FALSE_;}
get		{return GET_;}
height		{return HEIGHT_;}
hide		{return HIDE_;}
off		{return OFF_;}
on		{return ON_;}
n		{return N_;}
no		{return NO_;}
reset		{return RESET_;}
show		{return SHOW_;}
true		{return TRUE_;}
update		{return UPDATE_;}
version		{return VERSION_;}
width		{return WIDTH_;}
y		{return Y_;}
yes		{return YES_;}

[+-]?{D}+	{ // Integer
		  mglval->integer = atoi(yytext);
		  return INT;
		}

0[xX][0-9a-fA-F]+ { // Pointer
		  mglval->ptr = (void*)strtoul(yytext,NULL,16);
		  return POINTER;
		}

[ \t]+		{ // White Spaces
		} 

.		{ // Else, return the char
		  return yytext[0];
		}

%%