summaryrefslogtreecommitdiffstats
path: root/parser.c
Commit message (Collapse)AuthorAgeFilesLines
* * parser.c (open_txr_file): Bugfix: the name of the parsedKaz Kylheku2015-07-131-1/+1
| | | | | stream should be the resolved name, not the abstract original, so that error messages correlate to the file.
* Handle setting of parse name through prime_parser.Kaz Kylheku2015-07-101-3/+4
| | | | | | | | | | | | * parser.c (prime_parser): Take name as argument, and install it into parser. (lisp_parser): Pass name to parse, instead of setting it in the parser object. * parser.y (parse): Take name as argument and pass down to prime_parser. * parser.h (prime_parser, parse): Declarations updated.
* Fix wrong name reported for errors in first top-level form.Kaz Kylheku2015-07-101-1/+2
| | | | | * parser.c (read_eval_stream): Get name of original stream, and pass that down to lisp_parse as the name argument.
* Fix off by one error line numbers for .tl files.Kaz Kylheku2015-07-101-3/+7
| | | | | * parser.c (read_eval_stream): Add terminating newline to the first line that was examined for hash bang.
* Remove unused "primer" member from parser_t.Kaz Kylheku2015-07-101-7/+4
| | | | | | | | | | | * parser.c (parser_mark, parser_common_init): Remove reference to primer. (parser): Don't take primer argument, remove reference to member. (ensure_parser): Don't take primer argument, don't pass to parser function. (lisp_parse): Don't pass primer string to ensure_parser. * parser.h (primer_t): Remove primer member. (parser): Declaration updated.
* Bugfix: lexer loses unmatched "hold char" between top-level forms.Kaz Kylheku2015-07-101-6/+11
| | | | | | | | | | | | | | | | | | Test case: file containing 4(prinl 3). Scanner consumes 4 and (. The ( is lost when the scanner is reset for the next call to yyparse, resulting in jut prinl being read and interpreted as a variable. * parser.c (prime_parser): If present, append hold byte to priming string. Takes parser_t * instead of parser, and returns void now. * parser.l (reset_scanner): Now returns int value, the value of the scanner's yy_hold_char variable which is nonzero when the scanner is hanging on to an unmatched byte of input. * parser.h (reset_scanner, prime_parser): Declarations updated. * parser.y (parse): Pass hold byte returned by reset_scanner to prime_parser.
* Parser cleanup: embed scanner in parser.Kaz Kylheku2015-07-091-6/+26
| | | | | | | | | | | | | | | | | | | | | | | * parser.c (parser_destroy): New GC finalizer static function. (parser_ops): Register parser_destroy. (parser_common_init): New function, shared by parse and parse_once. Initializes embedded scanner. (parser_cleanup): New function, shared by parse_once and parser_destroy. (parser): Use parser_common_init. * parser.h (parser_t): New member, yyscan. (reset_scanner, parser_common_init): Declared. * parser.l (reset_scanner): New function. * parser.y (parse_once): Use parser_common_init, and thus perform only a few initializations. Do not define scanner as a local variable. (parse): Call reset_scanner instead of yylex_init since the scanner is being reused, and for the same reason do not call yylex_destroy. GC will do that now.
* Hash-bang support for .tl files.Kaz Kylheku2015-07-021-1/+10
| | | | | | | | | | | | | | | | * parser.c (read_eval_stream): New boolean argument to request hash bang support. * parser.h (read_eval_stream): Declaration updated. * eval.c (sys_load): Pass new thid argument to read_eval_stream, to decline hash bang support. * match.c (v_load): Likewise. * txr.c (txr_main): Request hash bang support from read_eval_stream. Thus files referenced from the txr command line can have a #! line, which is ignored.
* * parser.c (parser_mark): Do not mark p->syntax_tree ifKaz Kylheku2015-06-191-1/+2
| | | | | its value is nao. Introduced on 2015-06-10, "Error handling improvement in read".
* @(load) and @(include) now load Lisp code.Kaz Kylheku2015-06-121-0/+30
| | | | | | | | | | | * match.c (v_load): Check txr_lisp_p flag coming out of open_txr_file and handle the Lisp case usin read_eval_stream. * parser.c (read_eval_stream, get_parser, parser_errors): New functions. * parser.h (read_eval_stream, get_parser, parser_errors): Declared.
* Preparing for lisp loading.Kaz Kylheku2015-06-101-7/+58
| | | | | | | | | | | | | * parser.c (open_txr_file): Rewritten to take new argument which indicates whether to treat an unsuffixed file as TXR or TXR Lisp, and is updated to indicate which is the case by looking at the suffix. * parser.h (open_txr_file): Declaration updated. * match.c (v_load): Follow change in open_txr_file. * txr.c (txr_main): Likewise.
* Error handling improvement in read.Kaz Kylheku2015-06-101-4/+6
| | | | | | | | | | * parser.y (spec): New grammar production to handle the cases that SECRET_ESCAPE_E is not followed by anything (the input ends before any object is scanned, or there is no input token which starts an object). * parser.c (lisp_parse): Deal with EOF indication from parser (the syntax_tree member of parser_t set to nao).
* * parser.c (stream_parser_hash): New static variable.Kaz Kylheku2015-06-071-7/+47
| | | | | | | | | | | | | | | | | | (parser_mark): Mark parser and primer members. (parser, ensure_parser): new argument: primer. (get_parser_impl, ensure_parser): New static functions. (prime_parser): New function. (lisp_parse): Multiple calls to this function on the same stream now logically continue the parse, not resetting the line number to 1. (parse_init): Initialize and gc-protect stream_parser_hash. * parser.h (parser_t): New members, primer and parser. (prime_parser): Declared. (parser): Declaration updated. * parser.y (parse): Now responsible for calling prime_parser.
* * match.c (v_load): Call parse_once rater than parse.Kaz Kylheku2015-06-071-2/+2
| | | | | | | | | | | | | * parser.c (regex_parse): Likewise. * txr.c (txr_main): Likewise. * parser.h (parse): Declaration updated. (parse_once): Declared. * parser.y (parse_once): New function, same as old parse implementation. (parse): Becomes one argument function which works with a previously initialized parser and continues the parse.
* * Makefile (LISP_TO_C_STRING): Strip comments, but not comment lines,Kaz Kylheku2015-05-071-4/+5
| | | | | | | | | | | | | | | | | | so line numbers don't change. * eval.c (eval_init): Fix registrations of lisp-parse and read. * lisplib.c (place_instantiate): Give name to parsed string stream using new lisp_parse argument. * parser.c (lisp_parse): Takes new argument to override name. * parser.h (lisp_parse): Declaration updated. * txr.c (txr_main): Call lisp_parse with four args, defaulting the new one. * txr.1: Documented new argument.
* * parser.c (open_txr_file, regex_parse, lisp_parse): FunctionsKaz Kylheku2014-12-211-0/+77
| | | | | | | moved here from parser.l. * parser.l (open_txr_file, regex_parse, lisp_parse): Functions moved from here to parser.c.
* * Makefile (OBJS): Add parser.o.Kaz Kylheku2014-12-211-0/+89
* parser.h (parser_s): Declared. (parse_init): Declaration removed. (parser_l_init): Declared. * parser.l (parse_init): Function renamed to parser_l_init. * parser.c: New file.