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

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

More code...

File size: 5.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
49/* Holding an overriden method */
50typedef struct
51{
52 gchar* chrName; /* Name of this instance variable */
53 gchar* chrIntroducingIFace;
54}OVERMETHOD, *POVERMETHOD;
55
56#define PARM_DIRECTION_IN 1
57#define PARM_DIRECTION_OUT 2
58#define PARM_DIRECTION_INOUT 3
59/* Holding a method parameter */
60typedef struct
61{
62 guint uiDirection; /* in|out|inout */
63 gchar* chrType; /* Type e.g. gulong or GtkWidget */
64 guint uiStar; /* incremented for each '*' */
65 gchar* chrName;
66}METHODPARAM, *PMETHODPARAM;
67
68/* Holding a method */
69typedef struct
70{
71 gchar* chrRetType; /* Type e.g. gulong or GtkWidget */
72 gchar* chrName;
73 METHODPARAM mpReturn; /* We don't use all fields of this struct */
74 GPtrArray *pParamArray;
75}METHOD, *PMETHOD;
76
77/* Struct holding all the info of a defined or declared interface */
78typedef struct
79{
80 gchar* chrName; /* Name of this interface */
81 gchar *chrParent; /* Name of parent interface */
82 gulong ulMajor; /* Class version */
83 gulong ulMinor; /* Class version */
84 gboolean fIsForwardDeclaration;
85 GPtrArray *pMethodArray;
86 GPtrArray *pOverrideArray;
87 GPtrArray *pInstanceVarArray;
88}INTERFACE,*PINTERFACE;
89
90/* Info about a symbol */
91typedef struct
92{
93 gchar* chrSymbolName;
94 guint uiSymbolToken;
95 guint uiKind;
96}SYMBOL, *PSYMBOL;
97
98/* Such a struct can be found in GScanner->user_data */
99typedef struct
100{
101 const SYMBOL *pSymbols; /* List of our introduced symbols */
102 guint uiCurSymbolKind;
103 guint uiLineCorrection; /* This is the line number put by the preprocessor into
104 the source file. It's used to calculate proper line numbers
105 for errors. */
106 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
107 about their name. */
108}SYMBOLINFO,*PSYMBOLINFO;
109
110/* Symbols defined for our IDL language.
111 Keep these enums in sync with the order of the idlSymbols struct! */
112enum
113{
114 IDL_SYMBOL_INTERFACE=G_TOKEN_LAST+1,
115 IDL_SYMBOL_CLSVERSION,
116 IDL_SYMBOL_INSTANCEVAR,
117 IDL_SYMBOL_OVERRIDE,
118 /* Some GLib types */
119 IDL_SYMBOL_GULONG, /* 275 */
120 IDL_SYMBOL_GINT,
121 IDL_SYMBOL_GPOINTER,
122 IDL_SYMBOL_GBOOLEAN,
123 /* Direction of method parameters */
124 IDL_SYMBOL_IN,
125 IDL_SYMBOL_OUT,
126 IDL_SYMBOL_INOUT,
127 /* Preprocessor stuff (not yet supported by the compiler) */
128 IDL_SYMBOL_DEFINE,
129 IDL_SYMBOL_IFDEF,
130 IDL_SYMBOL_ENDIF
131};
132
133/* Specifies the kind of a token we read. For example we must
134 know if a read in indentifier is a type specification when
135 parsing method parameters. */
136enum
137{
138 KIND_UNKNOWN =1,
139 KIND_IDENTIFIER,
140 KIND_TYPESPEC, /* That's something like 'gint', 'gulong'... */
141 KIND_DIRECTION /* in, out, inout */
142};
143
144PINTERFACE findInterfaceFromName(gchar* chrName);
145
146void parseTypeSpec(PMETHODPARAM pMethodParam);
147void parseMethod(void);
148void parseInstanceVar(void);
149void parseInterface(GTokenType token);
150void parseClassVersion(void);
151void parseClassVersion(void);
152void parseOverrideMethod(void);
153void parseHash(void);
154void parsePreprocLineInfo(void);
155
Note: See TracBrowser for help on using the repository browser.