summaryrefslogtreecommitdiff
path: root/src/gram.c
Commit message (Collapse)AuthorAgeFilesLines
* Typo.Akim Demaille2002-09-041-5/+5
|
* (grammar_dump): Wrap strings in _() if they need translation.Paul Eggert2002-08-121-9/+10
| | | | Do not assume ptrdiff_t fits in int.
* * src/conflicts.c (conflicts_output): Don't output rules neverAkim Demaille2002-08-021-10/+70
| | | | | | | | | | | | | | | | | | reduced here, since anyway that computation doesn't work. * src/gram.h, src/gram.h (rule_filter_t, rule_useful_p) (rule_useless_p, rule_never_reduced_p): New. (grammar_rules_partial_print): Use a filter instead of a range. Display the title only if needed. (grammar_rules_print): Adjust. (grammar_rules_never_reduced_report): New. * src/tables.c (action_row): Move the computation of rules never reduced to... (token_actions): here. * src/main.c (main): Make the parser before making the report, so that rules never reduced are computed. Call grammar_rules_never_reduced_report. * src/print.c (print_results): Report rules never reduced. * tests/conflicts.at, tests/reduce.at: Adjust.
* Stop storing rules from 1 to nrules + 1.Akim Demaille2002-07-251-9/+9
| | | | | | | | | | | | | | | | | | * src/LR0.c, src/closure.c, src/derives.c, src/gram.c, src/lalr.c * src/nullable.c, src/output.c, src/print.c, src/reader.c * src/reduce.c: Allocate and free from &rules[0], not &rules[1]. Iterate from 0 to nrules. Use rule_number_as_item_number and item_number_as_rule_number. Adjust to `derive' now containing possibly 0. * src/gram.h (rule_number_as_item_number, item_number_as_rule_number): Handle the `- 1' part in rule numbers from/to item numbers. * src/conflicts.c (log_resolution): Fix the message which reversed shift and reduce. * src/output.c (action_row): Initialize default_rule to -1. (token_actions): Adjust. * tests/sets.at (Nullable, Firsts): Fix the previously bogus expected output. * tests/conflicts.at (Resolved SR Conflicts): Likewise.
* We spend a lot of time in quotearg, in particular when --verbose.Akim Demaille2002-06-301-6/+6
| | | | | | * src/symtab.c (symbol_get): Store a quoted version of the key. (symbol_tag_get, symbol_tag_get_n, symbol_tag_print): Remove. Adjust all callers.
* Display items as we display rules.Akim Demaille2002-06-301-21/+28
| | | | | | | | | | | * src/gram.h, src/gram.c (rule_lhs_print): New. * src/gram.c (grammar_rules_partial_print): Use it. * src/print.c (print_core): Likewise. * tests/conflicts.at (Defaulted Conflicted Reduction), (Unresolved SR Conflicts): Adjust. (Unresolved SR Conflicts): Adjust and rename as... (Resolved SR Conflicts): this, as was meant. * tests/regression.at (Web2c Report): Adjust.
* * src/gram.h (rule_number_t, RULE_NUMBER_MAX, int_of_rule_number)Akim Demaille2002-06-301-40/+53
| | | | | | | | | (item_number_of_rule_number, rule_number_of_item_number): New. * src/LR0.c, src/closure.c, src/derives.c, src/derives.h, * src/gram.c, src/lalr.c, src/nullable.c, src/output.c, src/print.c, * src/print_graph.c, src/reader.c, src/reduce.c, src/reduce.h: Propagate their use. Much remains to be done, in particular wrt `shorts' from types.h.
* Initial check-in introducing experimental GLR parsing. See entry inPaul Hilfinger2002-06-281-0/+2
| | | | ChangeLog dated 2002-06-27 from Paul Hilfinger for details.
* * src/gram.h, src/gram.c (grammar_rules_partial_print): New, evedAkim Demaille2002-06-151-6/+20
| | | | | | | | out of... (grammar_rules_print): here. * src/reduce.c (reduce_output): Use it. * tests/reduce.at (Useless Rules, Reduced Automaton) (Underivable Rules): Adjust.
* Copy BYacc's nice way to report the grammar.Akim Demaille2002-06-151-10/+78
| | | | | | | | * src/gram.h, src/gram.c (grammar_rhs_print, grammar_rules_print): New. Don't print the rules' location, it is confusing and useless. (rule_print): Use grammar_rhs_print. * src/print.c (print_grammar): Use grammar_rules_print.
* Move symbols handling code out of the reader.Akim Demaille2002-06-101-2/+0
| | | | | | | | | | | | | | | | | | | * src/reader.h, src/reader.c (errtoken, undeftoken, eoftoken) (axiom): Move to... * src/symtab.h, src/symtab.c: here. * src/gram.c (start_symbol): Remove: use startsymbol->number. * src/reader.c (startval): Rename as... * src/symtab.h, src/symtab.c (startsymbol): this. * src/reader.c: Adjust. * src/reader.c (symbol_check_defined, symbol_make_alias) (symbol_check_alias_consistence, symbol_pack, symbol_translation) (token_translations_init) Move to... * src/symtab.c: here. * src/reader.c (packsymbols): Move to... * src/symtab.h, src/symtab.c (symbols_pack): here. * src/symtab.h, src/symtab.c (symbol_make_alias): Takes SYMVAL as argument.
* * src/LR0.c, src/derives.c, src/gram.c, src/gram.h, src/lalr.c,Akim Demaille2002-05-261-2/+2
| | | | | | | | | | | * src/nullable.c, src/output.c, src/print.c, src/print_graph.c, * src/reader.c, src/reduce.c, src/state.h, src/symtab.h (token_number_t, item_number_as_token_number) (token_number_as_item_number, muscle_insert_token_number_table): Rename as... (symbol_number_t, item_number_as_symbol_number) (symbol_number_as_item_number, muscle_insert_symbol_number_table): these, since it is more appropriate.
* Kill GCC warnings.Akim Demaille2002-05-071-2/+2
| | | | | | | | | | | | | * src/reduce.c (nonterminals_reduce): Don't loop over RITEM: loop over the RHS of each rule. * src/gram.h, src/gram.c (nritems): Is `unsigned int', not int. * src/state.h (state_t): Member `nitems' is unsigned short. * src/LR0.c (get_state): Adjust. * src/reader.c (packgram): Likewise. * src/output.c (GENERATE_MUSCLE_INSERT_TABLE): `max' is of type `Type'. (muscle_insert_int_table): Remove, unused. (prepare_rules): Remove `max'.
* * src/output.c (GENERATE_OUTPUT_TABLE): Replace with...Akim Demaille2002-05-051-0/+11
| | | | | | | | | | | | | | | | (GENERATE_MUSCLE_INSERT_TABLE): this. (output_int_table, output_unsigned_int_table, output_short_table) (output_token_number_table, output_item_number_table): Replace with... (muscle_insert_int_table, muscle_insert_unsigned_int_table) (muscle_insert_short_table, muscle_insert_token_number_table) (muscle_insert_item_number_table): these. Adjust all callers. (prepare_tokens): Don't free `translations', since... * src/reader.h, src/reader.c (grammar_free): do it. Move to... * src/gram.h, src/gram.c (grammar_free): here. * data/bison.simple, data/bison.c++: b4_token_number_max is now b4_translate_max.
* Remove the so called hairy (semantic) parsers.Akim Demaille2002-05-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | * src/system.h (EXT_GUARD_C, EXT_STYPE_H): Remove. * src/gram.h, src/gram.c (semantic_parser): Remove. (rule_t): Remove the guard and guard_line members. * src/lex.h (token_t): remove tok_guard. * src/options.c (option_table): Remove %guard and %semantic_parser support. * src/output.c, src/output.h (guards_output): Remove. (prepare): Adjust. (token_definitions_output): Don't output the `T' tokens (???). (output_skeleton): Don't output the guards. * src/files.c, src/files.c (attrsfile): Remove. * src/reader.c (symbol_list): Remove the guard and guard_line members. Adjust dependencies. (parse_guard): Remove. * data/bison.hairy: Remove. * doc/bison.texinfo (Environment Variables): Remove occurrences of BISON_HAIRY.
* * src/reduce.c (dump_grammar): Move to...Akim Demaille2002-04-221-1/+60
| | | | | | * src/gram.h, src/gram.c (grammar_dump): here. Be sure to separate long item numbers. Don't read the members of a rule's prec if its nil.
* Propagate more token_number_t.Akim Demaille2002-04-221-1/+1
| | | | | | | | | | | | * src/gram.h (token_number_as_item_number) (item_number_as_token_number): New. * src/output.c (GENERATE_OUTPUT_TABLE): New. Use it to create output_item_number_table and output_token_number_table. * src/LR0.c, src/derives.c, src/gram.c, src/gram.h, src/lalr.c, * src/lex.c, src/nullable.c, src/output.c, src/print.c, * src/print_graph.c, src/reader.c, src/reduce.c, src/state.h, * src/symtab.c, src/symtab.h: Use token_number_t instead of shorts.
* * src/gram.h, src/gram.c (error_token_number): Remove, useAkim Demaille2002-04-091-2/+0
| | | | | | | | | | | | | | | | | | | | | | | errtoken->number. * src/reader.c (reader): Don't specify the user token number (2) for $undefined, as it uselessly prevents using it. * src/gram.h (token_number_t): Move to... * src/symtab.h: here. (state_t.number): Is a token_number_t. * src/print.c, src/reader.c: Use undeftoken->number instead of hard coded 2. (Even though this 2 is not the same as above: the number of the undeftoken remains being 2, it is its user token number which might not be 2). * src/output.c (prepare_tokens): Rename the `maxtok' muscle with `user_token_number_max'. Output `undef_token_number'. * data/bison.simple, data/bison.c++: Use them. Be sure to map invalid yylex return values to `undef_token_number'. This saves us from gratuitous SEGV. * tests/conflicts.at (Solved SR Conflicts) (Unresolved SR Conflicts): Adjust. * tests/regression.at (Web2c Actions): Adjust.
* * src/gram.h (item_number_t): New, the type of item numbers inAkim Demaille2002-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | RITEM. Note that it must be able to code symbol numbers as positive number, and the negation of rule numbers as negative numbers. Adjust all dependencies (pretty many). * src/reduce.c (rule): Remove this `short *' pointer: use item_number_t. * src/system.h (MINSHORT, MAXSHORT): Remove. Include `limits.h'. Adjust dependencies to using SHRT_MAX and SHRT_MIN. (shortcpy): Remove. (MAXTABLE): Move to... * src/output.c (MAXTABLE): here. (prepare_rules): Use output_int_table to output rhs. * data/bison.simple, data/bison.c++: Adjust. * tests/torture.at (Big triangle): Move the limit from 254 to 500. * tests/regression.at (Web2c Actions): Ajust. Trying with bigger grammars shows various phenomena: at 3000 (28Mb of grammar file) bison is killed by my system, at 2000 (12Mb) bison passes, but produces negative #line number, once fixed, GCC is killed while compiling 14Mb, at 1500 (6.7 Mb of grammar, 8.2Mb of C), it passes. * src/state.h (state_h): Code input lines on ints, not shorts.
* * src/muscle_tab.h (MUSCLE_INSERT_LONG_INT): New.Akim Demaille2002-04-071-1/+1
| | | | | | | | | | | | * src/output.c (output_table_data): Return the longest number. (prepare_tokens): Output `token_number_max'). * data/bison.simple, data/bison.c++ (b4_sint_type, b4_uint_type): New. Use them to define yy_token_number_type/TokenNumberType. Use this type for yytranslate. * tests/torture.at (Big triangle): Push the limit from 124 to 253. * tests/regression.at (Web2c Actions): Adjust.
* * src/gram.h, src/gram.c (nitems): Remove, it is an alias ofAkim Demaille2002-04-071-6/+5
| | | | | nritems. Adjust dependencies.
* Rename all the `bucket's as `symbol_t'.Akim Demaille2002-04-071-1/+1
| | | | | | | | | | | | | | | * src/gram.c, src/gram.h, src/lex.c, src/lex.h, src/output.c, * src/reader.c, src/reader.h, src/reduce.c, src/state.h, * src/symtab.c, src/symtab.h (bucket): Rename as... (symbol_t): this. (symbol_list_new, bucket_check_defined, bucket_make_alias) (bucket_check_alias_consistence, bucket_pack, bucket_translation) (bucket_new, bucket_free, hash_compare_bucket, hash_bucket) (buckets_new, buckets_free, buckets_do): Rename as... (symbol_list_new, symbol_check_defined, symbol_make_alias) (symbol_check_alias_consistence, symbol_pack, symbol_translation) (symbol_new, symbol_free, hash_compare_symbol_t, hash_symbol_t) (symbols_new, symbols_free, symbols_do): these.
* Use lib/hash for the symbol table.Akim Demaille2002-04-071-1/+1
| | | | | | | | | | | | | | | | | | | * src/gram.c (ntokens): Initialize to 1, to reserve a slot for EOF. * src/lex.c (lex): Set the `number' member of new terminals. * src/reader.c (bucket_check_defined, bucket_make_alias) (bucket_check_alias_consistence, bucket_translation): New. (reader, grammar_free, readgram, token_translations_init) (packsymbols): Adjust. (reader): Number the predefined tokens. * src/reduce.c (inaccessable_symbols): Just use hard coded numbers for predefined tokens. * src/symtab.h (bucket): Remove all the hash table related members. * src/symtab.c (symtab): Replace by... (bucket_table): this. (bucket_new, bucket_free, hash_compare_bucket, hash_bucket) (buckets_new, buckets_do): New.
* * src/gram.c (nitems, nrules, nsyms, ntokens, nvars, nritems)Akim Demaille2002-04-071-11/+11
| | | | | | | | | (start_symbol, max_user_token_number, semantic_parser) (error_token_number): Initialize. * src/reader.c (grammar, start_flag, startval, typed, lastprec): Initialize. (reader): Don't. (errtoken, eoftoken, undeftoken, axiom): Extern.
* * src/lalr.c, src/LR0.c, src/closure.c, src/gram.c, src/reduce.c:Akim Demaille2002-04-071-2/+4
| | | | Properly escape the symbols' TAG when outputting them.
* * src/gram.h, src/gram.c (rules_rhs_length): New.Akim Demaille2002-04-071-16/+23
| | | | | | | | | | | | (ritem_longest_rhs): Use it. * src/gram.h (rule_t): `number' is a new member. * src/reader.c (packgram): Set it. * src/reduce.c (reduce_grammar_tables): Move the useless rules at the end of `rules', and count them out of `nrules'. (reduce_output, dump_grammar): Adjust. * src/print.c (print_grammar): It is no longer needed to check for the usefulness of a rule, as useless rules are beyond `nrules + 1'. * tests/reduce.at (Reduced Automaton): New test.
* * src/closure.c, src/conflicts.c, src/derives.c, src/gram.cAkim Demaille2001-12-291-1/+1
| | | | | | * src/gram.h, src/lalr.c, src/nullable.c, src/output.c, src/print.c * src/print_graph.c, src/reader.c, src/reduce.c: Rename rule_table as rules.
* * src/gram.c (rprec, rprecsym, rassoc): Remove, unused since longAkim Demaille2001-12-291-3/+0
| | | | ago.
* * src/gram.c, src/gram.h (sprec, sassoc): Remove.Akim Demaille2001-12-291-3/+1
| | | | Adjust all users to use symbols[i]->prec or ->assoc.
* * src/reader.c, src/reader.h (tags): Remove.Akim Demaille2001-12-291-1/+1
| | | | Adjust all users to use symbols[i]->tag.
* * src/gram.h, src/gram.c (symbols): New, similar to state_tableAkim Demaille2001-12-291-0/+3
| | | | | | | | | | and rule_table. * src/reader.c (packsymbols): Fill this table. Drop sprec. * src/conflicts.c (resolve_sr_conflict): Adjust. * src/reduce.c (reduce_grammar): Adjust: just sort symbols, a single table. Use symbols[i]->tag instead of tags[i].
* * src/gram.c (ritem_print): Be sure to subtract 1 when displayingAkim Demaille2001-12-291-1/+1
| | | | | | | | rule line numbers. * src/closure.c (print_closure): Likewise. * src/derives.c (print_derives): Likewise. * tests/sets.at (Nullable): Adjust: the rule numbers are correct now.
* * src/LR0.c (generate_states): Use nritems, not nitems, nor usingAkim Demaille2001-12-291-3/+3
| | | | | | | | | the 0-sentinel. * src/gram.c (ritem_longest_rhs): Likewise. * src/reduce.c (nonterminals_reduce): Likewise. * src/print_graph.c (print_graph): Likewise. * src/output.c (output_rule_data): Likewise. * src/nullable.c (set_nullable): Likewise.
* Try to make the use of the eoftoken valid. Given that its valueAkim Demaille2001-12-271-2/+4
| | | | | | | | | | | | | | is 0 which was also used as a sentinel in ritem, (i) make sure >= 0 is used instead of > 0 where appropriate, (ii), depend upon nritems instead of the 0-sentinel. * src/gram.h, src/gram.c (nritems): New. Expected to be duplication of nitems, but for the time being... * src/reader.c (packgram): Assert nritems and nitems are equal. * src/LR0.c (allocate_itemsets, new_itemsets): Adjust. * src/closure.c (print_closure, print_fderives): Likewise. * src/gram.c (ritem_print): Likewise. * src/print.c (print_core, print_grammar): Likewise. * src/print_graph.c: Likewise.
* * src/reduce.c (reduce_grammar_tables): No longer disable theAkim Demaille2001-12-051-16/+13
| | | | | | | | removal of useless rules via CPP but via `if (0)', so that the compiler still check the code is valid. For instance, it should have noticed `rline' no longer exists: use the `line' member of rule_t. * src/gram.c (dummy, rline): Remove, unused.
* * src/lalr.c (maxrhs): Move to...Akim Demaille2001-12-051-0/+34
| | | | | * src/gram.c, src/gram.h (ritem_longest_rhs): here. * src/lalr.c (build_relations): Adjust.
* * src/gram.c, src/gram.h (ritem_print): New.Akim Demaille2001-12-051-4/+10
| | | | | | | | * src/gram.c (dummy): Remove, now there is actual code in gram.c. (This useless function was defined only to work around VMS linkers that can't handle compilation units with variables only). * src/reduce.c (dump_grammar): Use it to trace the construction of ritem.
* * src/gram.h (rule_t): New.Akim Demaille2001-11-191-3/+3
| | | | | | | | (rule_table): New. (rrhs, rlhs): Remove, part of state_t. * src/print_graph.c, src/closure.c, src/conflicts.c, src/derives.c, * src/lalr.c, src/nullable.c, src/output.c, src/print.c, * src/reader.c, src/reduce.c: Adjust.
* Merge in branch-1_29.after-merge-branch-1_29Akim Demaille2001-10-041-12/+10
|
* * src: s/Copyright (C)/Copyright/g.Akim Demaille2000-11-071-1/+1
|
* More explicit use of "const", "extern", and "static", particularly toJesse Thilo2000-07-041-0/+4
| | | | limit the scope of many local variables and functions.
* #Remove static from dummy().Jesse Thilo1999-01-201-1/+1
|
* Update FSF address.Jesse Thilo1999-01-141-1/+2
|
* Use prototypes if the compiler understands them.Jesse Thilo1998-12-301-2/+2
|
* entered into RCSDavid MacKenzie1991-11-031-0/+58