aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
Commit message (Collapse)AuthorAgeFilesLines
...
* | | 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.
* Handle the special case of a typedef to void funciton parameter to beBernhard Schommer2015-10-051-2/+2
| | | | handled as a function with void parameter.
* Allow redefinition of a typedef with the same name.Bernhard Schommer2015-10-043-7/+53
| | | | | C11 allows a typedef redefinition if the types are the same. We now allow this also and issue a warning and an error if the types are different.
* Merge pull request #57 from jhjourdan/parser_fixBernhard Schommer2015-10-015-160/+297
|\ | | | | Correction of a few bugs in the pre-parser, added comments.
| * Fixed a few bugs in the pre parser. In particular, the following codeJacques-Henri Jourdan2015-09-305-160/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | was not parsed correctly: typedef int a; int f() { for(int a; ;) if(1); a * x; } Additionnaly, I tried to add some comments in the pre-parser code, especially for the different hacks used to solve various conflicts.
* | Remove unused globals also from the debug informations.Bernhard Schommer2015-10-011-1/+6
| |
* | Added support for printing local variables and fixed issue with .textBernhard Schommer2015-09-231-0/+1
| | | | | | | | | | | | Local variables are now added with bogus lexical scopes to reflect the actually lexical scopes. Also this commit fixes assembler problems of the das when a user section with the name ".text" is defined.
* | Merge branch 'debugscopes' into debug_locationsBernhard Schommer2015-09-231-33/+37
|\ \ | | | | | | | | | | | | Conflicts: cparser/Unblock.ml
| * | Continuing experiment: track the scopes of local variables via __builtin_debugXavier Leroy2015-09-211-34/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As observed by B. Schommer, it is not enough to track scopes for every source line, as blocks can occur on a single line (think macros). Hence: - Revert debug annotations of kind 1 to contain only line number info. Generate them only when the line number changes. - Use debug annotations of kind 6 to record the list of active scopes (as BA_int integer arguments to __builtin_annot). Generate them before every nontrivial statement, even if on the same line as others. - Remove the generation of "variable x is declared in scope N" debug annotations. This can be tracked separately and more efficiently.
* | | Record the scope structure during unblocking.Bernhard Schommer2015-09-224-11/+18
| | | | | | | | | | | | | | | | | | Instead of creating separate annotations for the local variables we call the Debug.add_lvar_scope and we construct a mapping from function id + scope id to scope information.
* | | Merge branch 'debugscopes' into debug_locationsBernhard Schommer2015-09-213-39/+175
|\| | | | | | | | | | | | | | | | | Conflicts: debug/CtoDwarf.ml debug/DwarfPrinter.ml
| * | Experiment: track the scopes of local variables via __builtin_debug.Xavier Leroy2015-09-201-32/+132
| |/ | | | | | | | | | | | | | | | | | | | | C2C: the code that insert debug builtins with the line numbers is now in Unblock. Handle calls to __builtin_debug. Unblock: generate __builtin_debug(1) for line numbers, carrying the list of active scopes as extra arguments. Generate __builtin_debug(6) for local variable declarations, carrying the corresponding scope number as extra argument. Constprop: avoid duplicating debug arguments that are constants already. PrintAsmaux: show this extra debug info as comments.
| * Added support for bitfields in unions.Bernhard Schommer2015-09-171-6/+42
| | | | | | | | | | The transformation is the same as the one used for structs but packing always stops after each member.
| * Global register variables result in fatal error.Bernhard Schommer2015-09-081-1/+1
| | | | | | | | | | If they only report an error an assertion failure in Reame.ml was triggered.
* | New version of adding scopes etc.Bernhard Schommer2015-09-201-1/+1
| | | | | | | | | | Instead of reimplementing the whole scope handling in the debug information use the existing functionality and fill the scopes explicitly in the functions.
* | Started implementing the scope for the Debug Informations.Bernhard Schommer2015-09-181-1/+3
| | | | | | | | | | | | Scopes will be handled by a stack of all open scopes. This stack then can also be used to generate the debug directives to track the scopes through the rest of the passes.
* | First version with computation of dwarf info from debug info.Bernhard Schommer2015-09-172-4/+4
| | | | | | | | | | Introduced a new dwarf generation from the information collected in the DebugInformation and removed the old CtODwarf translation.
* | Move more functionality in the new interface.Bernhard Schommer2015-09-166-24/+43
|/ | | | | | Added functions to add more information to the debuging interface, like the struct layout with offsets, bitifiled layout and removed the no longer needed mapping from stamp to atom.
* Simplify the handling of extended inline asm, taking advantage of the new, ↵Xavier Leroy2015-08-211-6/+5
| | | | structured builtin arguments and results.
* Remove non digit and non letter chars from filename used in renaming of ↵Bernhard Schommer2015-07-151-0/+1
| | | | static variables to avoid problems with files such as "a b.c".
* Reject incomplete types as return type.Bernhard Schommer2015-07-141-1/+4
|
* Use env1 instead of env to also have the type specifiers used in the return ↵Bernhard Schommer2015-07-091-1/+1
| | | | parameter.
* Propagated the composed type constructed build during identifier lookup.Bernhard Schommer2015-07-091-6/+6
|
* Turn off copy optimization when returning a composite by reference.Xavier Leroy2015-07-081-4/+10
| | | | | | The copy optimization is not correct in case of overlap between destination and source. We would need to use an hypothetical __builtin_memmove_aligned that can cope with overlap to implement the copy at return of callee.
* Add implicit "return 0;" at end of function "main".Xavier Leroy2015-07-081-1/+13
| | | | | | | | As per ISO C99, "hosted environment". "return 0" is added at the end of any function named "main" that has "int" as return type. If the name is "main" but the return type is not "int", emit a warning and do not add anything.
* Turn "redefinition with an incompatible type" warning into an error.Xavier Leroy2015-07-081-1/+6
| | | | Also: improve error message by showing old and new types.
* Fix issue with bit fields of type _BoolXavier Leroy2015-07-081-6/+22
| | | | | | cparser/Bitfields.ml: when assigning to a bit field of type _Bool, the right-hand side must be normalized to 0 or 1 via a cast to _Bool. test/regression/bitfields{1,9}.c: add corresponding test cases.