-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexa.h
64 lines (56 loc) · 1.44 KB
/
lexa.h
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
/*
* lexa.h
*
* Copyright 2012-2014 Zdeněk Janeček <[email protected]>
*
* 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
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _LEX_H_
#define _LEX_H_
#define AT_FCE 1
#define AT_VAR 2
#define AT_NUM 3
#define AT_LBRACKET 4
#define AT_RBRACKET 5
#define AT_QUOTE 6
#define AT_UNKNOWN 7
#define FUNS_COUNT 22
enum ftype
{
ADD, SUB, MULT, DIV, QUOTE, SET, HELP, QUIT, CAR, CDR,
ABOUT, PRINT, DEFUN, EQ, EQQ, NEQ, GEQ, LEQ, LAND, LOR, BIF, LIST
};
typedef struct
{
int type;
union
{
char string[28];
int value;
};
} atom;
typedef struct
{
char lchar;
FILE *stream;
atom csym;
} lexa_state;
lexa_state lexa_init(lexa_state *s);
int lexa_next(atom *sym);
void lexa_get(atom *sym);
void lexa_flush();
const char *get_function_name(int id);
#endif