source: trunk/idl-compiler/include/parser.h@ 267

Last change on this file since 267 was 267, checked in by cinc, 18 years ago

Output file creation and better option parsing

File size: 5.9 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2* Version: CDDL 1.0/LGPL 2.1
3*
4* The contents of this file are subject to the COMMON DEVELOPMENT AND
5* DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6* this file except in compliance with the License. You may obtain a copy of
7* the License at http://www.sun.com/cddl/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is "NOM" Netlabs Object Model
15*
16* The Initial Developer of the Original Code is
17* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18* Portions created by the Initial Developer are Copyright (C) 2007
19* the Initial Developer. All Rights Reserved.
20*
21* Contributor(s):
22*
23* Alternatively, the contents of this file may be used under the terms of
24* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25* case the provisions of the LGPL are applicable instead of those above. If
26* you wish to allow use of your version of this file only under the terms of
27* the LGPL, and not to allow others to use your version of this file under
28* the terms of the CDDL, indicate your decision by deleting the provisions
29* above and replace them with the notice and other provisions required by the
30* LGPL. If you do not delete the provisions above, a recipient may use your
31* version of this file under the terms of any one of the CDDL or the LGPL.
32*
33* ***** END LICENSE BLOCK ***** */
34
35/* in token.c */
36void getNextToken(void);
37gboolean matchCur(GTokenType token);
38gboolean matchNext(GTokenType token);
39guint queryCurTokensKind(void);
40void printToken(GTokenType token);
41gboolean matchNextKind(guint uiKind);
42
43/* In printdata.c */
44void printInterface(void);
45
46
47#define IDL_COMPILER_STRING "IDL compiler" /* Used inside warnings and errors */
48#define ID_SCOPE 0
49
50/* Holding an overriden method */
51typedef struct
52{
53 gchar* chrName; /* Name of this instance variable */
54 gchar* chrIntroducingIFace;
55}OVERMETHOD, *POVERMETHOD;
56
57#define PARM_DIRECTION_IN 1
58#define PARM_DIRECTION_OUT 2
59#define PARM_DIRECTION_INOUT 3
60/* Holding a method parameter */
61typedef struct
62{
63 guint uiDirection; /* in|out|inout */
64 gchar* chrType; /* Type e.g. gulong or GtkWidget */
65 guint uiStar; /* incremented for each '*' */
66 gchar* chrName;
67}METHODPARAM, *PMETHODPARAM;
68
69/* Holding a method */
70typedef struct
71{
72 gchar* chrRetType; /* Type e.g. gulong or GtkWidget */
73 gchar* chrName;
74 METHODPARAM mpReturn; /* We don't use all fields of this struct */
75 GPtrArray *pParamArray;
76}METHOD, *PMETHOD;
77
78/* Struct holding all the info of a defined or declared interface */
79typedef struct
80{
81 gchar* chrName; /* Name of this interface */
82 gchar *chrParent; /* Name of parent interface */
83 gulong ulMajor; /* Class version */
84 gulong ulMinor; /* Class version */
85 gboolean fIsForwardDeclaration;
86 GPtrArray *pMethodArray;
87 GPtrArray *pOverrideArray;
88 GPtrArray *pInstanceVarArray;
89}INTERFACE,*PINTERFACE;
90
91/* Info about a symbol */
92typedef struct
93{
94 gchar* chrSymbolName;
95 guint uiSymbolToken;
96 guint uiKind;
97}SYMBOL, *PSYMBOL;
98
99/* Such a struct can be found in GScanner->user_data */
100typedef struct
101{
102 const SYMBOL *pSymbols; /* List of our introduced symbols */
103 guint uiCurSymbolKind;
104 guint uiLineCorrection; /* This is the line number put by the preprocessor into
105 the source file. It's used to calculate proper line numbers
106 for errors. */
107 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
108 about their name. */
109}SYMBOLINFO,*PSYMBOLINFO;
110
111typedef struct
112{
113 GTree* pSymbolTree; /* Our introduced symbols */
114 guint uiLineCorrection; /* This is the line number put by the preprocessor into
115 the source file. It's used to calculate proper line numbers
116 for errors. */
117 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
118 about their name. */
119 FILE* outFile; /* Output file handle */
120}PARSEINFO, *PPARSEINFO;
121
122/* Symbols defined for our IDL language.
123 Keep these enums in sync with the order of the idlSymbols struct! */
124enum
125{
126 IDL_SYMBOL_INTERFACE=G_TOKEN_LAST+1,
127 IDL_SYMBOL_CLSVERSION,
128 IDL_SYMBOL_INSTANCEVAR,
129 IDL_SYMBOL_OVERRIDE,
130 IDL_SYMBOL_REGINTERFACE, /* Used for registered interfaces */
131 IDL_SYMBOL_NATIVE,
132 /* Some GLib types */
133 IDL_SYMBOL_GULONG, /* 275 */
134 IDL_SYMBOL_GINT,
135 IDL_SYMBOL_GPOINTER,
136 IDL_SYMBOL_GBOOLEAN,
137 IDL_SYMBOL_GCHAR,
138 IDL_SYMBOL_VOID,
139 /* Legacy support */
140 IDL_SYMBOL_BOOLEAN,
141 IDL_SYMBOL_STRING,
142 /* Direction of method parameters */
143 IDL_SYMBOL_IN,
144 IDL_SYMBOL_OUT,
145 IDL_SYMBOL_INOUT,
146 /* Preprocessor stuff (not yet supported by the compiler) */
147 IDL_SYMBOL_DEFINE,
148 IDL_SYMBOL_IFDEF,
149 IDL_SYMBOL_ENDIF
150};
151
152/* Specifies the kind of a token we read. For example we must
153 know if a read in indentifier is a type specification when
154 parsing method parameters. */
155enum
156{
157 KIND_UNKNOWN =1,
158 KIND_IDENTIFIER,
159 KIND_TYPESPEC, /* That's something like 'gint', 'gulong'... */
160 KIND_DIRECTION /* in, out, inout */
161};
162
163PINTERFACE findInterfaceFromName(gchar* chrName);
164
165void parseTypeSpec(PMETHODPARAM pMethodParam);
166void parseMethod(void);
167void parseInstanceVar(void);
168void parseInterface(GTokenType token);
169void parseClassVersion(void);
170void parseClassVersion(void);
171void parseOverrideMethod(void);
172void parseHash(void);
173void parsePreprocLineInfo(void);
174
Note: See TracBrowser for help on using the repository browser.