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

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

IDL file parsing more or less working.

File size: 6.1 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 gchar* chrMetaClass; /* Pointer to metaclass name or NULL*/
87 GPtrArray *pMethodArray;
88 GPtrArray *pOverrideArray;
89 GPtrArray *pInstanceVarArray;
90}INTERFACE,*PINTERFACE;
91
92/* Info about a symbol */
93typedef struct
94{
95 gchar* chrSymbolName;
96 guint uiSymbolToken;
97 guint uiKind;
98}SYMBOL, *PSYMBOL;
99
100/* Such a struct can be found in GScanner->user_data */
101typedef struct
102{
103 const SYMBOL *pSymbols; /* List of our introduced symbols */
104 guint uiCurSymbolKind;
105 guint uiLineCorrection; /* This is the line number put by the preprocessor into
106 the source file. It's used to calculate proper line numbers
107 for errors. */
108 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
109 about their name. */
110}SYMBOLINFO,*PSYMBOLINFO;
111
112typedef struct
113{
114 GTree* pSymbolTree; /* Our introduced symbols */
115 guint uiLineCorrection; /* This is the line number put by the preprocessor into
116 the source file. It's used to calculate proper line numbers
117 for errors. */
118 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
119 about their name. */
120 FILE* outFile; /* Output file handle */
121}PARSEINFO, *PPARSEINFO;
122
123/* Symbols defined for our IDL language.
124 Keep these enums in sync with the order of the idlSymbols struct! */
125enum
126{
127 IDL_SYMBOL_INTERFACE=G_TOKEN_LAST+1,
128 IDL_SYMBOL_CLSVERSION,
129 IDL_SYMBOL_INSTANCEVAR,
130 IDL_SYMBOL_OVERRIDE,
131 IDL_SYMBOL_REGINTERFACE, /* Used for registered interfaces */
132 IDL_SYMBOL_CLSNAME,
133 IDL_SYMBOL_OLDMETACLASS,
134 IDL_SYMBOL_METACLASS,
135 IDL_SYMBOL_NATIVE,
136 /* Some GLib types */
137 IDL_SYMBOL_GULONG, /* 275 */
138 IDL_SYMBOL_GINT,
139 IDL_SYMBOL_GPOINTER,
140 IDL_SYMBOL_GBOOLEAN,
141 IDL_SYMBOL_GCHAR,
142 IDL_SYMBOL_VOID,
143 /* Legacy support */
144 IDL_SYMBOL_BOOLEAN,
145 IDL_SYMBOL_STRING,
146 IDL_SYMBOL_LONG,
147 IDL_SYMBOL_UNSIGNED,
148 /* Direction of method parameters */
149 IDL_SYMBOL_IN,
150 IDL_SYMBOL_OUT,
151 IDL_SYMBOL_INOUT,
152 /* Preprocessor stuff (not yet supported by the compiler) */
153 IDL_SYMBOL_DEFINE,
154 IDL_SYMBOL_IFDEF,
155 IDL_SYMBOL_ENDIF
156};
157
158/* Specifies the kind of a token we read. For example we must
159 know if a read in indentifier is a type specification when
160 parsing method parameters. */
161enum
162{
163 KIND_UNKNOWN =1,
164 KIND_IDENTIFIER,
165 KIND_TYPESPEC, /* That's something like 'gint', 'gulong'... */
166 KIND_DIRECTION /* in, out, inout */
167};
168
169PINTERFACE findInterfaceFromName(gchar* chrName);
170
171void parseTypeSpec(PMETHODPARAM pMethodParam);
172void parseMethod(void);
173void parseInstanceVar(void);
174void parseInterface(GTokenType token);
175void parseClassVersion(void);
176void parseClassVersion(void);
177void parseOverrideMethod(void);
178void parseHash(void);
179void parsePreprocLineInfo(void);
180void parseMetaClass(void);
Note: See TracBrowser for help on using the repository browser.