Commit Graph

960 Commits (8e801959e84e73219190dedad0b5b62b1f4f50a3)

Author SHA1 Message Date
Hugo Heuzard 921ad493b9 cleanup lexer
rebase
2018-09-24 17:59:23 -05:00
Sébastien Hinderer 9b28ccdc16 Break long lines introduced by 9046dc6219 2018-09-20 11:13:44 +02:00
Hugo Heuzard aa0fa8215f CR 2018-09-17 17:41:11 +08:00
Hugo Heuzard 9046dc6219 update error 2018-09-17 17:41:11 +08:00
Hugo Heuzard 63ed31c369 improve errors 2018-09-17 17:41:11 +08:00
Hugo Heuzard a28ad56b12 report error inside semantic action 2018-09-17 17:41:11 +08:00
Hugo Heuzard b560605fde fix newline char 2018-09-17 17:41:11 +08:00
Armaël Guéneau d213f9a808 Use a dummy value for line numbers in dummy locations 2018-09-13 09:33:37 +01:00
Florian Angeletti 558530a8b4 manual: compiler-libs.mld -> compiler_libs.mld 2018-09-12 16:32:37 +02:00
Florian Angeletti ef135a71ae
MPR7546, manual: preambles and warnings for compiler-libs modules (#2020)
* preambles for compiler-libs modules

* Compilerlibs intro and warning link
2018-09-12 09:51:47 +02:00
Armael a3fb865714 Improve the formatting of sub-errors in error/warning reports (#2035)
* Improve the formatting of sub-errors in error/warning reports

This avoids indenting sub-errors on the right of "Error:" (or "Warning x:"), and
implements more compact printing (the sub-location message is printed on the same
line of the location if it can fit).

* Extend the formatting test demonstrating report printing
2018-09-10 10:04:38 +02:00
François Pottier 9914bbde11 Fix two long lines. 2018-09-09 00:25:09 +02:00
François Pottier dac0cc969b Simplified definition of [core_type_list]. 2018-09-09 00:24:38 +02:00
François Pottier fe32d3fbac Simplified definition of [name_tag_list]. 2018-09-09 00:24:38 +02:00
François Pottier 076fc7c7c7 Definition of [preceded_or_separated_nonempty_llist], currently unused. 2018-09-09 00:24:38 +02:00
François Pottier f687cc0f28 Simplified definition of [amper_type_list]. 2018-09-09 00:24:38 +02:00
François Pottier a296147add Simplified definition of [row_field_list]. 2018-09-09 00:24:38 +02:00
François Pottier 5f8c4e8304 Simplified definitions of [poly_type] and [poly_type_no_attr]. 2018-09-09 00:24:38 +02:00
François Pottier 5d4b9f22c3 Simplified definition of [typevar_list]. 2018-09-09 00:24:38 +02:00
François Pottier 13ca153d10 Simplified definition of [type_parameter_list]. 2018-09-09 00:24:38 +02:00
François Pottier d5fafa251b Simplified definition of [optional_type_parameter_list]. 2018-09-09 00:24:38 +02:00
François Pottier 534b0aa0ce [pattern_semi_list] was always followed with [opt_semi]; simplified.
This saves two states.
2018-09-09 00:24:38 +02:00
François Pottier bc6374162b Simplified definition of [pattern_semi_list]. 2018-09-09 00:24:38 +02:00
François Pottier c1b9a90a96 [expr_semi_list] was always followed with [opt_semi].
Update the definition of [expr_semi_list] so that this is no longer necessary.
This is prettier and saves 4 states.
2018-09-09 00:24:38 +02:00
François Pottier 21a24b5ddc Simplified definition of [expr_semi_list]. 2018-09-09 00:24:38 +02:00
François Pottier 5e8981dea7 Simplify the definition of [field_expr_list]. Saves one state. 2018-09-09 00:24:38 +02:00
François Pottier 055c523a88 An equivalent (shorter) definition of [separated_or_terminated_nonempty_list]. 2018-09-09 00:24:38 +02:00
François Pottier 3354ac73a2 Simplified definition of [lbl_expr_list]. 2018-09-09 00:24:38 +02:00
François Pottier 1644e418a0 Introduce [separated_or_terminated_nonempty_list(delimiter, X)]. 2018-09-09 00:24:38 +02:00
François Pottier 94835f5f1e Replace the definition of [expr_comma_list] with an equivalent instance
of a generic definition.
2018-09-09 00:24:38 +02:00
François Pottier 4622d89312 Define [separated_nonempty_llist]. 2018-09-09 00:24:38 +02:00
François Pottier 4d6280a81c Replace [expr_comma_list] with [expr] in an unclosed-brace error production.
The use of [expr_comma_list] seemed to be a mistake.
2018-09-09 00:24:38 +02:00
François Pottier 1b3139e2ba Define [lident_list] as [mkrhs(LIDENT)+]. 2018-09-09 00:24:38 +02:00
François Pottier fc6e822447 Define [nonempty_llist].
Use it to eliminate [simple_labeled_expr_list].
2018-09-09 00:24:37 +02:00
François Pottier 53f5841532 Use [llist] instead of [list] in the names of some nonterminal symbols,
so as to indicate that they are left-recursive. (We reserve [list] for 
right-recursive lists, as in the Menhir standard library.)
2018-09-09 00:24:37 +02:00
Gabriel Scherer e024eeecd8 Makefile rules to test parser changes by comparing -dparsetree output 2018-09-08 12:24:29 +02:00
Gabriel Scherer 6c49b67bf6 mention Menhir in parsing/HACKING.adoc 2018-09-08 12:24:29 +02:00
Gabriel Scherer 5ea7058e75 parser.mly: consistently use $sloc over $loc
Menhir has two keywords to describe "the current source position",
$loc and $sloc. $sloc is more precise (it is included within $loc),
and the two differ only when the production starts with empty symbols,
and the difference only spans over whitespace.

We originally used $loc by default to emulate ocamlyacc behavior,
but $sloc is generally preferable, so this PR converts all locations
to use $sloc.

(Note: the location-of-a-symbol keyword remains $loc(...), for example
$loc($1) or $loc(foo), there is no $sloc version of those.)
2018-09-07 23:35:57 +02:00
Hugo Heuzard 0814a7261f The parser keeps previous location when relocating ast node 2018-09-06 16:12:00 +01:00
François Pottier a5e026e3f9 Parser: in the definition of [simple_core_type], replace
[core_type_comma_list] with [core_type], as this is what is really intended:
allow a single type. This removes the need for raising [Parsing.Parse_error]
in the semantic action, and should fix bug #7847. This change alone would
create a conflict in the grammar, which is avoided by replacing
[core_type_comma_list] with [inline_core_type_comma_list] in two places.
2018-09-04 17:20:52 +02:00
François Pottier d1af719c7d Parser: introduce a generic definition of [reversed_separated_nonempty_list]
and use it to give a more concise definition of [core_type_comma_list]. This
should make no difference whatsoever: the generated LALR(1) automaton should
be the same (up to some possible differences in naming).
2018-09-04 17:19:37 +02:00
Gabriel Scherer d09349f631 rename parsing/parser_menhir into parsing/parser 2018-09-01 23:17:06 +02:00
Gabriel Scherer e6ecea4008 remove the yacc parser
The large diff in boot/menhir/parser_menhir.ml comes from the fact
that the token list is now included in it, instead of being merely
a reference to the yacc parsers' Parser.token type.
2018-09-01 23:17:06 +02:00
Frédéric Bour f0daa4c564 a custom parsing loop that stop consuming top-level input on error 2018-09-01 23:17:06 +02:00
Gabriel Scherer 03767fb142 Menhir parser: silence the Pervasives deprecation warning 2018-09-01 23:17:05 +02:00
Gabriel Scherer e1086d5487 menhir parser: fix lapply 2018-09-01 23:17:05 +02:00
Frédéric Bour 002b975105 Parse.skip_phrase: store last token rather than finding it with Parsing.is_current_lookahead 2018-09-01 23:17:05 +02:00
Gabriel Scherer e5d91e1afc menhir parser: make check-typo happy 2018-09-01 23:17:04 +02:00
Gabriel Scherer c2e445f655 Revert "parser.mly: use prefixed+currified helpers to facilitate Menhir port"
This reverts commit f0b7535d228c47b4343ab6268c760db9c4912b57.

Those changes to the ocamlyacc parser helped during the yacc->menhir
transition, as they allowed to make the semantic action code
indentical between the yacc and menhir parser, which makes rebasing
against new yacc-parser versions much easier.

Instead of removing the change from the history, we revert it
explicitly so that we can easiy come back later to the non-reverted
version for testing or rebasing.
2018-09-01 23:17:04 +02:00
Gabriel Scherer 305127b39b menhir parser: make location-passing API more regular, remove {with,only}_loc 2018-09-01 23:17:04 +02:00