diff --git a/inc/definition.h b/inc/definition.h index c3c3621..eb79400 100644 --- a/inc/definition.h +++ b/inc/definition.h @@ -8,6 +8,28 @@ #include #include +#include + + +typedef enum +{ + CARROT_PATTERN_ELEMENT_VARIABLE_TERMINAL, + CARROT_PATTERN_ELEMENT_LITERAL_TERMINAL, + CARROT_PATTERN_ELEMENT_RULE +} carrot_pattern_element_e; + +typedef enum +{ + CARROT_VARIABLE_TERMINAL_ALPHABETICAL_WORD, + CARROT_VARIABLE_TERMINAL_ALPHANUMERIC_WORD, // + CARROT_VARIABLE_TERMINAL_KEYWORD, // Subtype of CARROT_VARIABLE_TERMINAL_ALPHANUMERIC_WORD; from a list of user-specified keywords. + CARROT_VARIABLE_TERMINAL_OPERATOR, + CARROT_VARIABLE_TERMINAL_NUMBER, + CARROT_VARIABLE_TERMINAL_FLOAT, // Subtype of CARROT_VARIABLE_TERMINAL_NUMBER; all numbers, including those with digits after the number. + CARROT_VARIABLE_TERMINAL_INTEGER // Subtype of CARROT_VARIABLE_TERMINAL_NUMBER; only means full numbers without digits after the number. +} carrot__variable_terminal_e; + + // carrot_definition_unit_s: A whole file (with possible included sub-files) of rules. // A definition unit describes a single format or language. typedef struct carrot_definition_unit carrot_definition_unit_s; @@ -37,26 +59,38 @@ typedef struct carrot_pattern_element carrot_pattern_element_s // in exactly the way as it was stated in the definition. typedef struct carrot_terminal carrot_terminal_s; -struct carrot_definition { +struct carrot_definition_unit +{ + uint32_t num_rules; + carrot_rule_definition_s *rules; + carrot_token_stream_s *token_stream; }; -struct carrot_rule_definition { +struct carrot_rule_definition +{ + carrot_definition_unit_s *syntax_definition; + uint32_t num_applying_patterns; + carrot_pattern_sequence_s *applying_patterns; }; -struct carrot_pattern { +struct carrot_pattern_sequence +{ + // rule: The rule that this pattern sequence belongs to. + carrot_rule_definition_s *rule; + uint32_t num_items; + carrot_pattern_element_s *items; }; -struct carrot_pattern_element { +struct carrot_pattern_element +{ + carrot_pattern_element_e type; + carrot__variable_terminal_e variable_terminal; + char *referenced_rule_name; + char *literal_terminal; }; -struct carrot_terminal { - -}; - - - #endif