aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parse_productions.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-12-15 14:59:03 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-12-19 11:17:13 -0800
commit8c707a4e2ffc30bae6d9ac3a28bd05fca0ff1195 (patch)
tree786b8ac916b5c873be902e8e3a1cbf9b38aaf53c /src/parse_productions.h
parent7188d94c1bdc483e6dca877631ca6dfa6af0ebbc (diff)
Simplify parser implementation
Rather than returning a list of productions and an index, return the relevant production directly from the rule function. Also introduce a tag value (replacing production_idx) which tracks information like command decorations, etc. with more clarity.
Diffstat (limited to 'src/parse_productions.h')
-rw-r--r--src/parse_productions.h15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/parse_productions.h b/src/parse_productions.h
index 1d64ccfc..ce456544 100644
--- a/src/parse_productions.h
+++ b/src/parse_productions.h
@@ -15,23 +15,12 @@ struct parse_token_t;
namespace parse_productions
{
-#define MAX_PRODUCTIONS 5
#define MAX_SYMBOLS_PER_PRODUCTION 6
-typedef uint32_t production_tag_t;
-
/* A production is an array of unsigned char. Symbols are encoded directly as their symbol value. Keywords are encoded with an offset of LAST_TOKEN_OR_SYMBOL + 1. So essentially we glom together keywords and symbols. */
typedef uint8_t production_element_t;
-
-/* An index into a production option list */
-typedef uint8_t production_option_idx_t;
-
-/* A production is an array of production elements */
typedef production_element_t const production_t[MAX_SYMBOLS_PER_PRODUCTION];
-/* A production options is an array of (possible) productions */
-typedef production_t production_options_t[MAX_PRODUCTIONS];
-
/* Resolve the type from a production element */
inline parse_token_type_t production_element_type(production_element_t elem)
{
@@ -65,8 +54,8 @@ inline bool production_element_is_valid(production_element_t elem)
return elem != token_type_invalid;
}
-/* Fetch a production. We are passed two input tokens. The first input token is guaranteed to not be invalid; the second token may be invalid if there's no more tokens. */
-const production_t *production_for_token(parse_token_type_t node_type, const parse_token_t &input1, const parse_token_t &input2, production_option_idx_t *out_which_production, wcstring *out_error_text);
+/* Fetch a production. We are passed two input tokens. The first input token is guaranteed to not be invalid; the second token may be invalid if there's no more tokens. We may also set flags. */
+const production_t *production_for_token(parse_token_type_t node_type, const parse_token_t &input1, const parse_token_t &input2, uint8_t *out_tag);
}