summaryrefslogtreecommitdiffstats
path: root/parser.y
Commit message (Collapse)AuthorAgeFilesLines
* * parser.y (all_clause, some_clause, none_clause, maybe_clause,Kaz Kylheku2011-10-011-12/+12
| | | | | cases_clause, choose_clause, elem): Regression bug fix: bad list calls in parser, lacking nao terminator.
* Regression bug fix: longest match variables broken byKaz Kylheku2011-10-011-1/+1
| | | | | | | | 2011-09-28 commit which introduced the double var match. * match.c (match_line): Handle case where modifier is t. * parser.y (var_op): Produce modifir as (t) rather than t.
* New directive: choose.Kaz Kylheku2011-10-011-13/+33
| | | | | | | | | | | | | | | | | | | | | | * match.c (choose_s, longest_k, shortest_k): New variables. (match_line, match_files): Introduced choose directive. (match_init): Initialize new variables. * match.h (choose_s): Declared. * parser.l (yybadtoken): Handle CHOOSE. (CHOOSE): Clause added for returning this token. * parser.y: Added #include "match.h". (CHOOSE): New token symbol. (choose_clause): New nonterminal symbol. (clause): choose_clause added. (all_clause, some_clause, none_clause, maybe_clause, cases_clause): Abstract syntax tree tweaked. (choose_clause): New syntax. (elem): Abstract syntax trees tweaked for many clauses. New CHOOSE clauses. (out_clause): New error case for choose_clause.
* * match.c (match_line): Implemented horizontal all, some,Kaz Kylheku2011-09-291-1/+20
| | | | | | | | | | none, maybe and cases directives. (match_files): Recognize horizontal version of these directives by the presence of the extra symbol t and do not process. Also, bugfix in the all directive: not resetting the all_match flag when short circuiting out. * parser.y (clause_parts_h, additional_parts_h): New nonterminals. (elem): New clauses added.
* * match.c (chars_k): New variable.Kaz Kylheku2011-09-291-3/+3
| | | | | | | | | | | | (match_line): Keyword arguments in coll implemented. (match_init): chars_k variable initialized. * parser.l (COLL): Lexical syntax changed to allow for argument material. * parser.y (elem): Coll syntax rewritten for arguments. * txr.1: Updated.
* * match.c (mingap_k, maxgap_k, gap_k, times_k, lines_k): NewKaz Kylheku2011-09-291-19/+26
| | | | | | | | | | | | | | | | | symbol variables. (match_lines): Keyword arguments in collect implemented. (match_init): New function. * match.h (match_init): Declared. * parser.l (COLLECT): Lexical syntax changed for COLLECT to allow for argument material. * parser.y (%union): obj renamed to val. (exprs_opt): New nonterminal. (collect_clause): Rewritten for arguments. * txr.c (main): Call to match_init introduced.
* * match.c (match_line): Logic restructured to allow forKaz Kylheku2011-09-281-3/+31
| | | | | | | | | | | | | | | | | | regex variables which also have nested variables. Previously this code was assuming that the cases were mutually exclusive, and the parser happened to work that way. Also, added support for a "double var" match which occurs when an unbound variable is followed by a regex variable. This case should be allowed because it makes sense. It's similar to a variable followed by a regex, except that the regex is also a variable binding. * parser.y (o_elems_transform): New function. (o_elems_opt, o_elems_opt2, quasilit): Transform o_elems with new function. This is needed because subst_vars doesn't deal with the nested var syntax for consecutive variables. (var): New syntax case '{' IDENT exprs '}' elem. This allows consecutive variables to be nested in all cases.
* * parser.y ('{', '}'): Nope, still not right.Kaz Kylheku2011-09-271-2/+1
| | | | | These must have exactly the same precedence as IDENT for this to work right, of course.
* * parser.y ('{', '}'): Bugfix: precedence of theseKaz Kylheku2011-09-271-1/+2
| | | | | | | terminals was causing @foo@foo to be parsed differently from @foo@{foo}. We need consecutive variables to be specially folded in the syntax under a single var_s node.
* Bugfixes: Consistent escaping in various literals. DoubleKaz Kylheku2011-09-261-0/+2
| | | | | | | | | | backslash codes for single backslash. Output clause can be empty. * parser.l (char_esc): Backslash handled. Use internal_error rather than abort. (REGCHAR, LITCHAR): Backslash added to lexical syntax. * parser.y (output_clause): Allow empty output clause.
* Filtering feature for variable substitution in output.Kaz Kylheku2011-09-251-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * filter.c, filter.h: New files. * Makefile (OBJS): filter.o added. * gc.c (mark_obj): Mark new alloc field of string objets. * hash.c (struct hash): New member, userdata. (hash_mark): Mark new userdata member of hash. (make_hash): Initialize userdata. (get_hash_userdata, set_hash_userdata, hashp): New functions. * hash.h (get_hash_userdata, set_hash_userdata, hashp): New functions declared. * lib.c (getplist, string_extend, cobjp): New functions. (string_own, string, string_utf8): Initialize new alloc field to nil. (mkstring, mkustring): Initialize new alloc field to actual size. (length_str): When length is computed and cached, also compute and cache alloc. (init): Call filter_init. * lib.h (string string): New member, alloc. (num_fast): Macro converted to inline function. (getplist, string_extend, cobjp): New functions declared. * match.c (match_line): Follows change of modifier s-exp syntax. (format_field): New parameter, filter. New modifier syntax parsed. Filter retrieved, and applied. (subst_vars): New parameter, filter. Filter is either applied in this function or passed to format_field, as needed. (eval_form): Pass nil to new parameter of subst_vars. (do_output_line): New parameter, filter. Passed down to subst_vars. (do_output): New parameter, filter. Passed down to do_output_line. (match_files): Pass nil filter to subst_vars in cat directive. Output directive refactored to parse keywords, extract the filter and pass down to do_output. * parser.y (regex): Generate (sys:regex regex syntax ...) instead of (regex syntax ...). (elem, expr): Updated w.r.t. regex syntax change. (var): Cases '{' IDENT regex '}' and '{' IDENT NUMBER '}' are removed. new syntax '{' IDENT exprs '}' to handle these more generally and allow for keywords. * txr.1: Updated.
* * LICENSE, Makefile, configure, gc.c, gc.h, hash.c, hash.h, lib.c,Kaz Kylheku2011-09-231-1/+1
| | | | | | lib.h, match.c, match.h, parser.h, parser.l, parser.y, regex.c, regex.h, stream.c, stream.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Updated copyright year.
* * match.c, parser.y: Support for old output syntax removed.Kaz Kylheku2011-09-231-2/+3
| | | | | | Leading :nothrow with trailing material is an error now. * txr.1: Updated. Made note of errors in pipes being asynchronous.
* Bump copyrights to 2010.Kaz Kylheku2010-10-051-1/+1
|
* More regex grammar work.Kaz Kylheku2010-01-191-1/+2
|
* Whitespace.Kaz Kylheku2010-01-191-1/+1
|
* Resolving parser conflicts.Kaz Kylheku2010-01-191-17/+20
|
* * parser.y (regterm, regclass): Relocate handlingKaz Kylheku2010-01-171-3/+3
| | | | of empty [] into regterm, via empty derivation.
* Regex syntactic tweaks: support the [] syntaxKaz Kylheku2010-01-161-0/+2
| | | | | to match no character and [^] as its complement, being synonymous with the wildcard dot.
* Implemented non-greedy operator.Kaz Kylheku2010-01-151-2/+6
|
* Bugfix: allow unescaped / to be used in regex character classes.Kaz Kylheku2010-01-131-2/+4
|
* * parser.y (precedence): bugfix: character classes like this [^*]Kaz Kylheku2010-01-131-1/+2
| | | | being treated as a non-complemented set of two characters.
* Impelement derivative-based regular expressions.Kaz Kylheku2010-01-131-7/+7
|
* Some fine tuning in regex grammar.Kaz Kylheku2010-01-061-2/+2
|
* Implemented the regular expression ~ and & operators.Kaz Kylheku2010-01-051-2/+6
| | | | | | | | | | | | | | | This turns out to be easy to do in NFA land. The complement of an NFA has exactly the same number and configuration of states and transitions, except that the states have an inverted meaning; and furthermore, failed character transitions are routed to an extra state (which in this impelmentation is permanently allocated and shared by all regexes). The regex & is implemented trivially using DeMorgan's. Also, bugfix: regular expressions like A|B|C are allowed now by the syntax, rather than constituting syntax error. Previously, this would have been entered as (A|B)|C.
* * parser.y (grammar): Fixes for bison 2.4.1. Remove superfluous actionKaz Kylheku2009-11-261-2/+1
| | | | in chrlit. Include <stdlib.h> for abort.
* Fix a build breakage that may happen on some platforms.Kaz Kylheku2009-11-251-0/+2
| | | | | | | | | The parser.y file includes "utf8.h", which uses the the type wint_t. It also includes "lib.h" which uses "wchar_t". But it fails to include any headers which define these types. The generated y.tab.c picks up wchar_t by the Bison-inserted inclusion of <stdlib.h>, so that's how we got that. But wint_t does not come from any of the headers---if they are standard-conforming.
* Fixed broken yyerrorf. It was still taking char *, and passingKaz Kylheku2009-11-241-32/+39
| | | | | that as an object to vformat, resulting in #<garbage: ...> output.
* Renaming global variables that denote symbols, such that theyKaz Kylheku2009-11-241-52/+53
| | | | have a _s suffix.
* Improving portability. It is no longer assumed that pointersKaz Kylheku2009-11-231-1/+2
| | | | | | | | can be converted to a type long and vice versa. The configure script tries to detect the appropriate type to use. Also, some run-time checking is performed in the streams module to detect which conversions specifier strings to use for printing numbers.
* Introducing symbol packages. Internal symbols are now inKaz Kylheku2009-11-211-12/+14
| | | | | | | | | | a system package instead of being hacked with the $ prefix. Keyword symbols are provided. In the matcher, evaluation is tightened up. Keywords, nil and t are not bindeable, and errors are thrown if attempts are made to bind them. Destructuring in dest_bind is strict in the number of items. String streams are exploited to print bindings to objects that are not strings or characters. Numerous bugfixes.
* * parser.y (grammar): Fix error actions that do not assignKaz Kylheku2009-11-201-12/+23
| | | | a value to $$.
* Changing ``obj_t *'' occurences to a ``val'' typedef. (Ideally,Kaz Kylheku2009-11-201-22/+22
| | | | | we wouldn't have to declare object variables at all, so why use an obtuse syntax to do so?)
* Big conversion to wide characters and UTF-8 support.Kaz Kylheku2009-11-111-2/+3
| | | | | | | | | This is incomplete. There are too many dependencies on wide character support from the C stream I/O library, and implicit use of some encoding which may not be UTF-8. The regex code does not handle wide characters properly. Character type is still int in some places, rather than wchar_t. Test suite passes though.
* Start of implementation for freestyle matching.Kaz Kylheku2009-11-021-14/+23
| | | | | | | | | | | Lazy strings implemented, incompletely. Changed string function to implicitly strdup; non-strdup version changed to string_own. Fixed wrong uses of strdup rather than chk_strdup. Functions added to regex module to provide regex matching as a state machine to which characters are fed.
* txr-016 2009-10-16txr-016Kaz Kylheku2017-07-311-13/+28
|
* txr-015 2009-10-15txr-015Kaz Kylheku2017-07-311-0/+593