aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/pre_parser.mly
Commit message (Collapse)AuthorAgeFilesLines
* [BROKEN] Merge with v3.9 : something broken for __builtin_expect in ↵Cyril SIX2021-06-011-4/+5
| | | | cfrontend/C2C.ml
* Merge branch 'master' (Absint 3.8) into kvx-work-merge3.8David Monniaux2020-11-181-1/+7
|\
| * Allow string_literals_list in _Static_assert.Bernhard Schommer2020-07-271-1/+1
| | | | | | | | | | | | Not all pre-processors concatenate string literal lists, however they are allowed in _Static_assert. This is similar to the rules for inline assembly etc.
| * Support _Static_assert from C11Xavier Leroy2020-07-211-1/+7
| |
* | parse _Thread_localDavid Monniaux2020-02-241-1/+2
|/
* New parser based on new version of the Coq backend of Menhir (#276)Jacques-Henri Jourdan2019-07-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | What's new: 1. A rewrite of the Coq interpreter of Menhir automaton, with dependent types removing the need for runtime checks for the well-formedness of the LR stack. This seem to cause some speedup on the parsing time (~10% for lexing + parsing). 2. Thanks to 1., it is now possible to avoid the use of int31 for comparing symbols: Since this is only used for validation, positives are enough. 3. Speedup of Validation: on my machine, the time needed for compiling Parser.v goes from about 2 minutes to about 1 minute. This seem to be related to a performance bug in the completeness validator and to the use of positive instead of int31. 3. Menhir now generates a dedicated inductive type for (semantic-value-carrying) tokens (in addition to the already existing inductive type for (non-semantic-value-carrying) terminals. The end result is that the OCaml support code for the parser no longer contain calls to Obj.magic. The bad side of this change is that the formal specification of the parser is perhaps harder to read. 4. The parser and its library are now free of axioms (I used to use axiom K and proof irrelevance for easing proofs involving dependent types). 5. Use of a dedicated custom negative coinductive type for the input stream of tokens, instead of Coq stdlib's `Stream`. `Stream` is a positive coinductive type, which are now deprecated by Coq. 6. The fuel of the parser is now specified using its logarithm instead of its actual value. This makes it possible to give large fuel values instead of using the `let rec fuel = S fuel` hack. 7. Some refactoring in the lexer, the parser and the Cabs syntax tree. The corresponding changes in Menhir have been released as part of version 20190626. The `MenhirLib` directory is identical to the content of the `src` directory of the corresponding `coq-menhirlib` opam package except that: - In order to try to make CompCert compatible with several Menhir versions without updates, we do not check the version of menhir is compatible with the version of coq-menhirlib. Hence the `Version.v` file is not present in CompCert's copy. - Build-system related files have been removed.
* Remove the `_Alignas(expr)` construct (#125)Xavier Leroy2018-06-071-1/+0
| | | | The `_Alignas(expr)` construct is not C11, only `_Alignas(type)` is.
* Remove shadowing openBernhard Schommer2017-02-061-1/+1
|
* Change the syntax to gcc/clangs syntax.Bernhard Schommer2017-02-011-1/+2
| | | | | | This only means that there must be one identifier at the begining and then a designator. Bug 20765
* New version to support designators.Bernhard Schommer2017-01-241-1/+1
| | | | | | | | | The c standard allows member designators for offsetof. The current implementation works by recursively combining the offset of each of the member designators. For array access the size of the subtypes is multiplied by the index and for members the offset of the member is calculated. Bug 20765
* Implement offsetof via builtin.Bernhard Schommer2017-01-201-1/+2
| | | | | | | | | | | | The implementation of offsetof as macro in the form ((size_t) &((ty*) NULL)->member) has the problem that it cannot be used everywhere were an integer constant expression is allowed, for example in initiliazers of global variables and there is also no check for the case that member is of bitifield type. The new implementation adds a builtin function for this which is replaced by an integer constant during elaboration. Bug 20765
* Merge pull request #95 from AbsInt/noreturnBernhard Schommer2016-04-041-1/+2
|\ | | | | Added the _Noreturn keyword.
| * Added the _Noreturn keyword.Bernhard Schommer2016-03-231-1/+2
| | | | | | | | | | | | | | | | CompCert now recognizes the C11 _Noreturn function specifier and emits a simple warning for functions declared _Noreturn containing a return statement. Also the stdnoreturn header and additionally the stdalign header are added. Bug 18541
* | Compatibility with newer ocaml versions. Bug 18313.Bernhard Schommer2016-03-311-1/+1
|/
* Fix a bug in the pre-parser.Jacques-Henri Jourdan2016-03-231-0/+1
|
* A simplification in the grammar, leading to fewer states in the automatonFrançois Pottier2015-11-241-6/+3
| | | | and merging two error states into one. There should be no observable change.
* Typo, coherence in error messagesJacques-Henri Jourdan2015-11-071-3/+4
|
* Integrate a few comments of F. Pottier into the pre_parser and ↵Jacques-Henri Jourdan2015-11-071-9/+39
| | | | handcrafted.messages
* Merge remote-tracking branch 'origin/master' into parser_fixJacques-Henri Jourdan2015-11-041-144/+252
|\
| * Added copyright banners to the new files.François Pottier2015-10-231-0/+1
| |
| * 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.
| * 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.