blob: 7966a2a3d21c9a947dbb5fb997aaca7fa9e60025 [file] [log] [blame]
Carl Wortha1e32bc2010-05-10 13:17:25 -07001/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef GLCPP_H
25#define GLCPP_H
26
Carl Worth0b27b5f2010-05-10 16:16:06 -070027#include "hash_table.h"
Carl Wortha1e32bc2010-05-10 13:17:25 -070028
29#define yyscan_t void*
30
Carl Worth33cc4002010-05-12 12:17:10 -070031/* Some data types used for parser value. */
Carl Worth0b27b5f2010-05-10 16:16:06 -070032
Carl Worth610053b2010-05-14 10:05:11 -070033typedef struct string_node {
Carl Worth33cc4002010-05-12 12:17:10 -070034 const char *str;
Carl Worth610053b2010-05-14 10:05:11 -070035 struct string_node *next;
36} string_node_t;
Carl Worth33cc4002010-05-12 12:17:10 -070037
Carl Worth610053b2010-05-14 10:05:11 -070038typedef struct string_list {
39 string_node_t *head;
40 string_node_t *tail;
41} string_list_t;
Carl Worth33cc4002010-05-12 12:17:10 -070042
Carl Worth8f6a8282010-05-14 10:44:19 -070043typedef struct argument_node {
44 string_list_t *argument;
45 struct argument_node *next;
46} argument_node_t;
47
48typedef struct argument_list {
49 argument_node_t *head;
50 argument_node_t *tail;
51} argument_list_t;
52
Carl Worth33cc4002010-05-12 12:17:10 -070053typedef struct glcpp_parser glcpp_parser_t;
54
55glcpp_parser_t *
56glcpp_parser_create (void);
Carl Worth0b27b5f2010-05-10 16:16:06 -070057
58int
59glcpp_parser_parse (glcpp_parser_t *parser);
60
61void
Carl Worth33cc4002010-05-12 12:17:10 -070062glcpp_parser_destroy (glcpp_parser_t *parser);
Carl Worth0b27b5f2010-05-10 16:16:06 -070063
Carl Worthfcbbb462010-05-13 09:36:23 -070064typedef enum {
65 MACRO_TYPE_UNDEFINED,
66 MACRO_TYPE_OBJECT,
67 MACRO_TYPE_FUNCTION
68} macro_type_t;
69
70macro_type_t
71glcpp_parser_macro_type (glcpp_parser_t *parser,
72 const char *identifier);
Carl Worth9f62a7e2010-05-13 07:38:29 -070073
Carl Worth0b27b5f2010-05-10 16:16:06 -070074/* Generated by glcpp-lex.l to glcpp-lex.c */
75
Carl Wortha1e32bc2010-05-10 13:17:25 -070076int
Carl Worth5070a202010-05-12 12:45:33 -070077yylex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner);
Carl Wortha1e32bc2010-05-10 13:17:25 -070078
79int
80yylex (yyscan_t scanner);
81
82int
83yylex_destroy (yyscan_t scanner);
84
85/* Generated by glcpp-parse.y to glcpp-parse.c */
86
87int
Carl Worth0b27b5f2010-05-10 16:16:06 -070088yyparse (glcpp_parser_t *parser);
Carl Wortha1e32bc2010-05-10 13:17:25 -070089
Carl Worth5070a202010-05-12 12:45:33 -070090/* xtalloc - wrappers around talloc to check for out-of-memory */
91
92#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type)
93
94void *
95xtalloc_named_const (const void *context, size_t size, const char *name);
96
97char *
98xtalloc_strdup (const void *t, const char *p);
99
Carl Wortha1e32bc2010-05-10 13:17:25 -0700100#endif