aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
Commit message (Collapse)AuthorAgeFilesLines
* Set [ErrorReports.debug] to [false].François Pottier2015-10-281-1/+1
| | | | | | When [debug] is [false], there are a few places where we silently ignore an error. This should not make any difference if everything works as planned.
* Fixed some comments.François Pottier2015-10-281-16/+16
|
* Merge pull request #61 from fpottier/cleanBernhard Schommer2015-10-261-5/+1
|\ | | | | Fixed one error message and removed two comments.
| * Fixed one error message and removed two comments.François Pottier2015-10-261-5/+1
| |
* | Also redirect the output of stderr.Bernhard Schommer2015-10-261-2/+1
|/ | | | Bug 17481.
* Merge remote branch 'upstream/master' into cleanFrançois Pottier2015-10-2327-160/+206
|\ | | | | | | | | Conflicts: Makefile.extr
| * Merge branch 'clean' of https://github.com/fpottier/CompCert into fpottier-cleanBernhard Schommer2015-10-201-84/+104
| |\ | | | | | | | | | | | | Conflicts: Makefile.extr
| * | bug 17392: remove trailing whitespace in source filesMichael Schmidt2015-10-149-40/+40
| | |
| * | bug 17392: remove trailing whitespace in source filesMichael Schmidt2015-10-1418-122/+122
| | |
| * | Move strip functions to Cutil.Bernhard Schommer2015-10-122-0/+46
| | | | | | | | | | | | | | | | | | Since the strip functions might be useful in other context and is more general then the debug information. Bug 17392.
* | | Added copyright banners to the new files.François Pottier2015-10-237-0/+82
| | |
* | | Added a few cleanup commands in [make clean].François Pottier2015-10-231-1/+1
| | |
* | | Added some handwritten .c files in tests/handwritten/.François Pottier2015-10-2311-0/+59
| | |
* | | Install the new system for reporting syntax errors.François Pottier2015-10-237-6/+5777
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires the development version of Menhir, to be released soon. In summary: handcrafted.messages is new. It contains a mapping of erroneous sentences to error messages, together with a lot of comments. Makefile.extr is new. It contains a rule to generate cparser/pre_parser_messages.ml based on this mapping. cparser/ErrorReports.{ml,mli} are new. They construct syntax error messages, based on the compiled mapping. cparser/Lexer.mll is modified. The last two tokens that have been read are stored in a buffer. ErrorReports is called to construct a syntax error message. cparser/GNUmakefile is new. It offers several commands for working on the pre-parser. cparser/deLexer.ml is new. It is a script (it is not linked into CompCert). It translates the symbolic name of a token to an example of this token in concrete C syntax. It is used by [make -C cparser concrete] to produce the .c files in tests/generated/. cparser/tests/generated/Makefile is new. It runs ccomp, clang and gcc on each of the generated C files, so as to allow a comparison of the error messages.
* | | Lexer update: use Menhir's incremental API instead of Menhir's traditional API.François Pottier2015-10-231-3/+16
| | | | | | | | | | | | | | | This means that CompCert must now be compiled in --table mode. At this point, the error message for a syntax error is still just "syntax error".
* | | Lexer cleanup: isolate [lexer_wraper] and rename it to [lexer].François Pottier2015-10-231-6/+10
| | |
* | | Lexer cleanup: isolate the entry point into the lexer.François Pottier2015-10-231-6/+10
| | |
* | | Added an %on_error_reduce declaration.François Pottier2015-10-231-0/+42
| | | | | | | | | | | | | | | This affects in which states errors are detected, but does not change the language that is accepted.
* | | Changed [asm_flags] to a left-recursive list.François Pottier2015-10-231-1/+1
| | | | | | | | | | | | This allows us to give a better error message in one state.
* | | Removed the two uses of $syntaxerror in a semantic action.François Pottier2015-10-231-2/+7
| | | | | | | | | | | | | | | | | | | | | For the first one, this is fine; the error is caught by a type check later on. For the second one, it is temporary. More thought is needed about the syntax of K&R functions anyway, as Jacques-Henri and I discovered that it is currently broken (it mis-interprets some function definitions).
* | | Inlined [constant_expression] to save one state.François Pottier2015-10-231-1/+1
| | |
* | | Reformulated [specifier_qualifier_list_no_typedef_name] as a left-recursive ↵François Pottier2015-10-231-4/+4
| | | | | | | | | | | | | | | | | | list. This saves 7 states and 4 error states.
* | | Redefined [pointer] as a left-recursive list.François Pottier2015-10-231-7/+24
| | | | | | | | | | | | | | | This creates more states and does not change the number of error states. It should make it easier to give a good error message in at least 2 states.
* | | Replaced [declaration_specifiers_no_typedef_name] with ↵François Pottier2015-10-231-7/+3
| | | | | | | | | | | | | | | | | | | | | [declaration_specifier_no_typedef_name*]. This replaces a right-recursive list with a left-recursive list. This saves 2 states and 6 error states.
* | | Factorized [declaration_specifier_no_typedef_name].François Pottier2015-10-231-5/+9
| | | | | | | | | | | | This results in slightly fewer states.
* | | Reformulated the definitions of [option] and [list] in a slightly more ↵François Pottier2015-10-231-11/+13
| | | | | | | | | | | | elegant manner.
* | | Introduced [list] and [ilist]. Redefined [declaration_specifiers_no_type] as ↵François Pottier2015-10-231-11/+22
| | | | | | | | | | | | | | | | | | a left-recursive list. This further reduces the number of states (and error states).
* | | Factorized [declaration_specifier_no_type].François Pottier2015-10-231-3/+7
| | | | | | | | | | | | This saves a few states.
* | | Added a phantom parameter to [declaration].François Pottier2015-10-231-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This parameter is passed down in [declaration_specifiers(declaration(phantom))]. This allows us to distinguish between three calling contexts for [declaration_specifiers]: - we are definitely in a parameter declaration; - we are definitely in a declaration (e.g., in a block); - we are in a declaration or in a function definition (i.e., at the top level). This allows us to give better error messages. For instance, when inside a block, we know that this cannot be the beginning of a function definition.
* | | Added a phantom parameter to [declaration_specifiers].François Pottier2015-10-231-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | This does not change the automaton at all. It allows us to distinguish more easily between two contexts: - the beginning of a declaration or function definition; - the beginning of a parameter declaration. This leads to better error messages.
* | | Added a phantom parameter to [abstract_declarator].François Pottier2015-10-231-4/+8
| | | | | | | | | | | | | | | | | | | | | This allows distinguishing two uses of abstract_declarator, within a type_name and within a parameter_declaration. This provides more static context and allows giving a better syntax error message, as this allows us know what is expected next: a closing parenthesis or a comma.
* | | Added a phantom parameter to [specifier_qualifier_list].François Pottier2015-10-231-3/+4
| | |
* | | A general comment about phantom parameters.François Pottier2015-10-231-0/+16
| | |
* | | Remove all productions that involve the [error] token.François Pottier2015-10-231-34/+0
| | | | | | | | | | | | | | | These productions were used to give better error messages in some situations. They are no longer useful, since we are building a whole new system for reporting errors.
* | | Added [Cerrors.fatal_error_raw].François Pottier2015-10-232-0/+13
| | |
* | | Read the whole source C file into memory instad of reading it on demand.François Pottier2015-10-232-5/+17
| | | | | | | | | | | | | | | Having the file in memory will help build an error message. Also, this may be slightly faster.
* | | Fix [Lexer.char_literal] and [Lexer.string_literal] to properly keep track ↵François Pottier2015-10-221-10/+12
| |/ |/| | | | | | | | | of [lex_start_p]. This is required for Menhir to pick up the correct start position of the token.
* | Replaced 4 uses of [ioption(declaration_specifiers_no_type)] with ↵François Pottier2015-10-081-4/+4
| | | | | | | | | | | | | | [declaration_specifiers_no_type?]. Inlining these options was not necessary. This reduces the number of states in the automaton.
* | Cosmetic. Removed some spaces. Shared one redundant semantic action {}.François Pottier2015-10-071-7/+6
| |
* | One cosmetic change of [option] to [?]. No impact.François Pottier2015-10-071-1/+1
| |
* | Factorized the two forms of FOR statement by introducing [for_statement_header].François Pottier2015-10-071-2/+6
| | | | | | | | This leads to a smaller automaton.
* | Introduced optional(X, Y), which means X? Y, and used it in array ↵François Pottier2015-10-071-4/+12
| | | | | | | | | | | | declarators and FOR loops. This leads to fewer automaton states, and potentially better error messages.
* | Factorized the productions for several categories of binary operators.François Pottier2015-10-071-13/+20
| | | | | | | | | | | | | | This leads to a small savings in the number of states (which could become greater in the future if we decide to parameterize expressions). If desired, the old automaton could be recovered by marking the binary operators as %inline.
* | Factorized two productions (and two error productions) in [enum_specifier].François Pottier2015-10-071-5/+2
| | | | | | | | This is analogous to the previous commit.
* | Factorized two productions (and two error productions) in ↵François Pottier2015-10-071-5/+2
| | | | | | | | | | | | | | | | | | | | | | [struct_or_union_specifier]. The old version was strictly equivalent to using [ioption(other_identifier)]. The new version uses [option(other_identifier)] instead, that is, [other_identifier?]. Technically, this means that [set_id_type i OtherId] is called slightly earlier (at the opening brace, instead of at the closing brace), but this does not make any difference, since the re-classification of identifiers affects only the second parsing phase.
* | For clarity, removed several redundant calls to [set_id_type].François Pottier2015-10-071-9/+5
| | | | | | | | | | | | | | A TYPEDEF_NAME is already classified as a [TypedefId] by the lexer, and similarly, a VAR_NAME is already classified as a [VarId]. Thus, the removed calls had no effect. The remaining calls to [set_id_type] are useful, as they can re-classify a token.
* | Introduced [other_identifier] as a more elegant way of calling [set_id_type ↵François Pottier2015-10-071-19/+22
| | | | | | | | | | | | i OtherId]. This causes no change in the automaton.
* | One more replacement of [ioption] with [option].François Pottier2015-10-071-1/+1
| | | | | | | | I missed this opportunity in the previous commit.
* | Use [option] as much as possible and [ioption] only where necessary.François Pottier2015-10-071-13/+30
| | | | | | | | | | | | | | | | | | The existing [option(X)] was marked %inline, and has been renamed [ioption(X)]. A new [option(X)], which is not marked %inline, has been introduced. The grammar now uses [option] everywhere, except where [ioption] is necessary in order to avoid conflicts. This reduces the number of states in the automaton. The number of LR(0) cores drops from 857 to 712.
* | Add whitespace, for better vertical alignment and better readability.François Pottier2015-10-071-21/+13
|/ | | | This violates the 80-column width limit, but is really important.