2 * Copyright 2012-2013, Jakub Zawadzki <darkjames-ws@darkjames.pl>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
59 #define NPL_PARAMS_MAX 20
62 char *args
[NPL_PARAMS_MAX
];
68 EXPRESSION_INVALID
= 0,
75 EXPRESSION_MULTI_INDEX
,
83 } npl_expression_type_t
;
85 typedef struct _npl_expression_list
{
86 struct _npl_expression_list
*next
;
88 struct _npl_expression
*expr
;
89 } npl_expression_list_t
;
91 typedef struct _npl_expression
{
94 npl_expression_type_t type
;
98 npl_expression_type_t type
; /* EXPRESSION_ID */
103 npl_expression_type_t type
; /* EXPRESSION_INT */
108 npl_expression_type_t type
; /* EXPRESSION_STR */
113 npl_expression_type_t type
; /* EXPRESSION_INDEX */
115 struct _npl_expression
*base
;
116 struct _npl_expression
*index
;
120 npl_expression_type_t type
; /* EXPRESSION_MULTI_INDEX */
122 struct _npl_expression
*base
;
123 npl_expression_list_t
*indexes
;
127 npl_expression_type_t type
; /* EXPRESSION_FIELD */
129 struct _npl_expression
*base
;
134 npl_expression_type_t type
; /* EXPRESSION_UNARY */
137 struct _npl_expression
*operand
;
142 npl_expression_type_t type
; /* EXPRESSION_BINARY */
144 struct _npl_expression
*operand1
;
145 struct _npl_expression
*operand2
;
151 npl_expression_type_t type
; /* EXPRESSION_CALL */
153 struct _npl_expression
*fn
;
154 npl_expression_list_t
*args
;
159 npl_expression_type_t type
; /* EXPRESSION_COND */
161 struct _npl_expression
*test_expr
;
162 struct _npl_expression
*true_expr
;
163 struct _npl_expression
*false_expr
;
170 struct _npl_statement
;
177 npl_expression_t
*format
;
178 npl_expression_t
*count_expr
;
179 struct _npl_statements
*sts
;
192 npl_expression_t
*switch_expr
;
194 struct npl_table_case
{
195 struct npl_table_case
*next
;
199 npl_expression_t
*return_expr
;
203 npl_expression_t
*default_expr
;
211 npl_expression_t expr
;
218 STATEMENT_INVALID
= 0,
225 STATEMENT_DYNAMIC_SWITCH
,
227 } npl_statement_type_t
;
230 npl_expression_t
*switch_expr
;
232 struct npl_switch_case
{
233 struct npl_switch_case
*next
;
237 struct _npl_statement
*st
;
241 struct _npl_statement
*default_st
;
245 typedef struct _npl_attribute_list
{
246 struct _npl_attribute_list
*next
;
247 struct _npl_expression
*expr
;
250 const char *resolved
;
251 npl_expression_t
*assign_expr
;
253 } npl_attribute_list_t
;
255 typedef struct _npl_statement
{
258 npl_statement_type_t type
;
259 npl_attribute_list_t
*attr_list
;
263 npl_statement_type_t type
; /* STATEMENT_WHILE */
264 npl_attribute_list_t
*attr_list
;
267 npl_expression_t expr
;
269 struct _npl_statements
*sts
;
273 npl_statement_type_t type
; /* STATEMENT_TABLE */
274 npl_attribute_list_t
*attr_list
;
280 npl_statement_type_t type
; /* STATEMENT_STRUCT */
281 npl_attribute_list_t
*attr_list
;
287 npl_statement_type_t type
; /* STATEMENT_SWITCH or STATEMENT_DYNAMIC_SWITCH */
288 npl_attribute_list_t
*attr_list
;
293 struct _npl_statement_field
{
294 npl_statement_type_t type
; /* STATEMENT_FIELD */
295 npl_attribute_list_t
*attr_list
;
301 npl_expression_t
*arr
;
303 npl_expression_t
*format
;
304 struct _npl_statements
*sts
;
305 npl_expression_list_t
*params
;
309 npl_expression_t
*byte_order_attr
;
317 struct _npl_statements
{
318 struct _npl_statements
*next
;
327 npl_expression_t
*format
;
328 struct _npl_statements
*sts
;
340 FIELD_UNSIGNED_NUMBER
345 npl_field_type_t type
;
350 npl_expression_t
*byte_order
;
351 npl_expression_t
*display_format
;
352 npl_expression_t
*size
;
374 npl_decl_type_t type
;
375 npl_attribute_list_t
*attr_list
;
379 npl_decl_type_t type
; /* DECL_INCLUDE */
380 npl_attribute_list_t
*attr_list
;
386 npl_decl_type_t type
; /* DECL_STRUCT */
387 npl_attribute_list_t
*attr_list
;
393 npl_decl_type_t type
; /* DECL_TABLE */
394 npl_attribute_list_t
*attr_list
;
400 npl_decl_type_t type
; /* DECL_PROTOCOL */
401 npl_attribute_list_t
*attr_list
;
407 npl_decl_type_t type
; /* DECL_CONST */
408 npl_attribute_list_t
*attr_list
;
414 npl_decl_type_t type
; /* DECL_TYPE */
415 npl_attribute_list_t
*attr_list
;
424 struct _npl_decl_list
{
425 struct _npl_decl_list
*next
;