54 #ifndef _S3_CONTEXT_FREE_GRAMMAR_H
55 #define _S3_CONTEXT_FREE_GRAMMAR_H
60 #include "prim_type.h"
61 #include "hash_table.h"
69 #define S3_CFG_MAX_RULE_STR_LEN 1023
70 #define S3_CFG_MAX_ITEM_STR_LEN 40
71 #define S3_CFG_MAX_ITEM_COUNT 20
72 #define S3_CFG_INITIAL_RULE_COUNT 1
73 #define S3_CFG_INITIAL_RULE_SET_COUNT 50
74 #define S3_CFG_INITIAL_PARSE_SET_COUNT 20
75 #define S3_CFG_PARSE_HASH_SIZE 251
76 #define S3_CFG_INITIAL_STATE_SET_COUNT 20
77 #define S3_CFG_INITIAL_TERM_COUNT 50
78 #define S3_CFG_NAME_HASH_SIZE 4091
80 #define S3_CFG_INVALID_SCORE 1.0f
81 #define S3_CFG_INITIAL_SCORE 0.0f
83 #define S3_CFG_NONTERM_PREFIX '$'
84 #define S3_CFG_TERM_BIT 0x80000000
85 #define S3_CFG_INDEX_MASK 0x7FFFFFFF
87 #define S3_CFG_INVALID_ID 0x7FFFFFFF
89 #define S3_CFG_PSTART_ITEM 0x00000000
90 #define S3_CFG_PSTART_ITEM_STR "$PSTART"
91 #define S3_CFG_START_ITEM 0x00000001
92 #define S3_CFG_START_ITEM_STR "$START"
93 #define S3_CFG_EOR_ITEM (0x00000002 | S3_CFG_TERM_BIT)
94 #define S3_CFG_EOR_ITEM_STR "#EOR#"
95 #define S3_CFG_EOI_ITEM (0x00000003 | S3_CFG_TERM_BIT)
96 #define S3_CFG_EOI_ITEM_STR "#EOI#"
97 #define S3_CFG_NIL_ITEM (0x00000004 | S3_CFG_TERM_BIT)
98 #define S3_CFG_NIL_ITEM_STR "#NIL#"
100 #define S3_CFG_START_RULE \
101 { S3_CFG_PSTART_ITEM, 0.0f, { S3_CFG_START_ITEM, S3_CFG_EOR_ITEM }, 1 }
103 #define S3_CFG_AUTO_PRUNE_SCORE 0x00000001
104 #define S3_CFG_AUTO_PRUNE_RANK 0x00000002
106 #define s3_cfg_is_null_parse(x) (x->entries.count == 0)
108 #define s3_cfg_is_terminal(x) (x & S3_CFG_TERM_BIT)
110 #define s3_cfg_id2index(x) (x & S3_CFG_INDEX_MASK)
302 s3_cfg_id_t *_products);