/
parser.h
92 lines (70 loc) · 2.59 KB
/
parser.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
87
88
89
90
91
92
/* Global variables from parse.y.
*/
/*
Copyright (C) 1991-2003 The National Gallery
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
/* Our input stream can be attached to either a string or a FILE.
* Keep track of the state of play here.
*/
typedef struct {
iOpenFile *of; /* Non-NULL if we read from a file */
char *str; /* Non-NULL if we read from a string */
char *strpos; /* Position in string */
char buf[MAX_STRSIZE]; /* Accumulate text of each definition here */
int bwp; /* Write point in the above */
int bsp[MAX_SSTACK]; /* Start point stack */
int bspsp; /* Stack pointer */
int lineno; /* Current line number */
int charno; /* Character in line */
int pcharno; /* Characters in previous line */
int charpos; /* Characters read by lex so far */
int oldchar; /* unget buffer, -1 for no unget */
} InputState;
extern InputState input_state;
/* Function declarations for parse.y.
*/
void nip2yyerror( const char *sub, ... )
__attribute__((format(printf, 1, 2)));
void yyerror( const char *msg );
extern int yyleng; /* lex stuff */
/* Lex gathers tokens here for workspace.c
*/
extern VipsBuf lex_text;
/* Attach input for lex.
*/
void attach_input_file( iOpenFile *of );
void attach_input_string( const char *str );
int ip_input( void );
void ip_unput( int ch );
void ip_unget( void );
gboolean is_EOF( void );
/* Parse stuff.
*/
/* Order and number important ... see table in parse_rhs()
*/
typedef enum {
PARSE_RHS = 0, /* eg. "a + b" */
PARSE_PARAMS, /* eg. "a b = a + b" */
PARSE_SUPER /* eg. "fred c d" */
} ParseRhsSyntax;
extern jmp_buf parse_error_point;
gboolean parse_toplevel( Toolkit *kit, int pos );
gboolean parse_onedef( Toolkit *kit, int pos );
gboolean parse_rhs( Expr *expr, ParseRhsSyntax syntax );
void free_lex( int yychar );
char *parse_test_define( void );
Symbol *parse_set_symbol( void );