-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntax.h
86 lines (71 loc) · 1.67 KB
/
syntax.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: syntax.h
* Author: Samuele Colombo
*
* Created on 12 febbraio 2016, 10.29
*/
#ifndef SYNTAX_H
#define SYNTAX_H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
int ival;
char *sval;
float rval;
bool bval;
} Lexval;
typedef enum {
TP_NONTERMINAL,
TP_ID,
TP_INTEGER,
TP_REAL,
TP_STRING,
TP_BOOLEAN,
TP_OPERATION,
TP_INTCONST,
TP_REALCONST,
TP_STRCONST,
TP_BOOLCONST
} TypeNode;
typedef enum {
NT_PROGRAM,
NT_STAT,
NT_DEF_STAT,
NT_ASSIGN_STAT,
NT_PROJECT_EXPR,
NT_SELECT_EXPR,
NT_JOIN_EXPR,
NT_UPDATE_EXPR,
NT_EXTEND_EXPR,
NT_RENAME_EXPR,
NT_READ_STAT,
NT_SPECIFIER,
NT_WRITE_STAT,
NT_REL_EXPR
} NonTerminal;
struct s_table;
typedef struct snode {
TypeNode type;
int expr_type;
Lexval value;
int line;
struct snode *child, *brother;
struct s_table * currentTable;
int attr_rel_expr; //indica dove andare a prendere attributo se da prima (1) o seconda (2) rel_expr
} Node;
typedef Node * PNode;
PNode parse(FILE *);
void treeprint(PNode node, int indent);
#ifdef __cplusplus
}
#endif
#endif /* SYNTAX_H */