Semtrex provides a language for pattern matching on semantic trees similar to regular expressions for matching on text strings.
More...
|
SState * | _stx_makeFA (T *s, int *statesP) |
|
void | _stx_freeFA (SState *s) |
|
int | _t_match (T *semtrex, T *t) |
|
int | _t_matchr (T *semtrex, T *t, T **r) |
|
T * | _stx_get_matched_node (Symbol s, T *match_results, T *match_tree, int *sibs) |
|
void | _stx_replace (T *semtrex, T *t, T *replace) |
|
T * | _t_get_match (T *result, Symbol group) |
|
T * | __t_embody_from_match (SemTable *sem, T *match, T *t) |
|
T * | _t_embody_from_match (SemTable *sem, T *match, Symbol group, T *t) |
|
char * | _dump_semtrex (SemTable *sem, T *s, char *buf) |
|
T * | makeASCIITree (char *c) |
|
T * | parseSemtrex (SemTable *sem, char *stx) |
|
T * | _stx_results2sem_map (SemTable *sem, T *match_results, T *match_tree) |
|
T * | __stxcv (T *stxx, char c) |
|
T * | __stxcvm (T *stxx, int not, int count,...) |
|
T * | asciiT_toi (T *asciiT, T *match, T *t, Symbol s) |
|
T * | asciiT_tol (T *asciiT, T *match, T *t, Symbol s) |
|
T * | asciiT_tof (T *asciiT, T *match, T *t, Symbol s) |
|
T * | asciiT_tos (T *asciiT, T *match, T *t, Symbol s) |
|
T * | asciiT_toc (T *asciiT, T *match, T *t, Symbol s) |
|
T * | wrap (T *tokens, T *results, Symbol contents_s, Symbol open_s) |
|
T * | __sl (T *p, bool not, int count,...) |
|
void | __stx_dump (SState *s, char *buf) |
|
char * | _stx_dump (SState *s, char *buf) |
|
void | stx_dump (T *s) |
|
Semtrex provides a language for pattern matching on semantic trees similar to regular expressions for matching on text strings.
Semantic Tree Regular Expressions (Semtrex for short) provide a matching language for semantic trees that will feel familiar to anyone who has used regular expressions for matching on strings.
A Semtrex is itself a semantic tree, but we have also created a linear textual representation of (and parser for) semtrex trees to make it easier to create them until we build better UI for processing trees in general.
Examples (with tree version and the parts of a sample tree that match in red)
Here's a BNF for the textual representation of semtrex trees:
<semtrex> ::= <root> [ "/" <child>...]
<root> ::= "/" <element>
<child> ::= <element> | <optional> | <semtrex>
<element> ::= <walk> | <symbol_literal> | <value_literal> | <symbol_literal_set> | <value_literal_set> | <any> | <capture> | <siblings>
<optional> ::= <or> | <zero_or_more> | <one_or_more> | <zero_or_one>
<walk> ::= "%" <semtrex>
<one_or_more> ::= <semtrex> "+"
<zero_or_more> ::= <semtrex> "*"
<zero_or_one> ::= <semtrex> "?"
<sequence> ::= <semtrex> ["," <semtrex>]...
<siblings> ::= "(" <sequence> ")"
<or> ::= <semtrex> "|" <semtrex>
<symbol_literal> ::= ["!"] <symbol>
<symbol_literal_set> ::= ["!"] "{" <symbol> ["," <symbol>]... "}"
<value> ::= <string> | <char> | Int | Fload
<value_literal> ::= <symbol> ["!"] "=" <value>
<value_literal_set> ::= <symbol> ["!"] "={" <value> ["," <value> ]... "}"
<any> ::= "."
<capture> ::= "<" <symbol> ":" <semtrex> ">"
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<letter> ::= a | b ... | z | A | B ... | Z
<special> ::= "_"
<symbol> ::= (<letter> | <digit> | <special>)+
<char> ::= "'" <letter> | <digit> | <special> "'"
<string> ::= "\"" (<letter> | <digit> | <special>)+ "\""
<float> ::= <digit>+ ["." <digit>+ ]