72 lines
1.6 KiB
C
72 lines
1.6 KiB
C
|
|
||
|
#ifndef PARCEL_AST_H
|
||
|
#define PARCEL_AST_H
|
||
|
|
||
|
#include <utility.h>
|
||
|
|
||
|
typedef struct pac_ast pac_ast_s;
|
||
|
typedef struct pac_ast_rule pac_ast_rule_s;
|
||
|
typedef struct pac_ast_variant pac_ast_variant_s;
|
||
|
typedef struct pac_ast_literal pac_ast_literal_s;
|
||
|
typedef struct pac_ast_reference pac_ast_reference_s;
|
||
|
typedef struct pac_ast_item pac_ast_item_s;
|
||
|
|
||
|
struct pac_ast
|
||
|
{
|
||
|
usz_t num_rules;
|
||
|
pac_ast_rule_s *rules;
|
||
|
};
|
||
|
|
||
|
struct pac_ast_rule
|
||
|
{
|
||
|
char *name;
|
||
|
|
||
|
usz_t num_variants;
|
||
|
pac_ast_variant_s *variants;
|
||
|
};
|
||
|
|
||
|
struct pac_ast_variant
|
||
|
{
|
||
|
usz_t num_items;
|
||
|
pac_ast_item_s *items;
|
||
|
};
|
||
|
|
||
|
// pac_ast_reference: Also called non-terminal, a reference is an item
|
||
|
// which represents all the contents of another rule.
|
||
|
struct pac_ast_reference
|
||
|
{
|
||
|
usz_t len_name;
|
||
|
char *name;
|
||
|
};
|
||
|
|
||
|
struct pac_ast_literal
|
||
|
{
|
||
|
usz_t length;
|
||
|
char *string;
|
||
|
};
|
||
|
|
||
|
// pac_outline_e: An enumeration of all outlines known to Parcel.
|
||
|
//
|
||
|
// Outlines are tokens of which only the rough format is known, like
|
||
|
// with variable names; the format is known, but the actual name isn't.
|
||
|
typedef enum
|
||
|
{
|
||
|
PAC_OUTLINE_RUNE,
|
||
|
PAC_OUTLINE_WORD,
|
||
|
PAC_OUTLINE_INTEGER,
|
||
|
PAC_OUTLINE_FLOAT
|
||
|
|
||
|
} pac_outline_e;
|
||
|
|
||
|
struct pac_ast_item
|
||
|
{
|
||
|
bool_t is_literal;
|
||
|
union pac_item_data
|
||
|
{
|
||
|
pac_ast_literal_s literal;
|
||
|
pac_outline_e outline;
|
||
|
} data;
|
||
|
};
|
||
|
|
||
|
#endif // PARCEL_AST_H
|