Rune - Generation work
[rune.git] / librune / parse.h
1 /*
2  * PARSE.H
3  *
4  * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved.  See the  
5  *    COPYRIGHT file at the base of the distribution.
6  */
7
8 struct IPNode;
9
10 typedef RUNE_HEAD(ipnodelist, IPNode) ipnodelist_t;
11
12 typedef struct IPNode {
13         RUNE_ENTRY(IPNode) ip_Node;
14         char    *ip_Path;
15         int     ip_Flags;
16 } IPNode;
17
18 #define IPF_STATIC      0x0001  /* embedded in some other structure */
19 #define IPF_ABSOLUTE    0x0002  /* treat path as absolute even if it isn't */
20 #define IPF_BASEPATH    0x0004  /* flag to prefix with basepath later */
21
22 typedef struct Parse {
23         Lex             *p_Lex;         /* lexical scanner */
24         token_t         p_Token;        /* lexical scanner */
25         Stmt            *p_Import;      /* parse file as import content */
26         Stmt            *p_CurStmt;     /* current statement */
27         SemGroup        *p_CurSemGroup; /* current semantic group */
28         IPNode          p_IPath;
29         int             p_Format;       /* source, pre-parsed, object, etc. */
30         int             p_ArgAc;        /* passed to main() */
31         char            **p_ArgAv;      /* passed to main() */
32         int32_t         p_RetVal;       /* ret value from main() (32 bit int) */
33         struct stat     p_St;           /* stat information to detect sharing */
34 } Parse;
35
36 #define PFMT_SOURCE     1
37 #define PFMT_PARSED     2
38 #define PFMT_RESOLVED   3
39
40 #define dassert_parse(p, type, cond)    if (!(cond)) ParseFatalError(p, type)
41
42 #define ParseFatalError(p, type)                        \
43             do {                                        \
44                     LexError(&(p)->p_Token, type);      \
45                     LexPrintError(&p->p_Token);         \
46                     dassert(0);                         \
47             } while(0)