From 581ac226fb42a0a005baa8941e5f39b181acc6cb Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 22 Oct 2015 18:09:36 +0200 Subject: Fix [Lexer.char_literal] and [Lexer.string_literal] to properly keep track of [lex_start_p]. This is required for Menhir to pick up the correct start position of the token. --- cparser/Lexer.mll | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index 5cfe74fd..6be59aa8 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -283,15 +283,15 @@ rule initial = parse currentLoc lexbuf)} | preprocessing_number as s { error lexbuf "invalid numerical constant '%s'@ These characters form a preprocessor number, but not a constant" s; CONSTANT (Cabs.CONST_INT "0", currentLoc lexbuf) } - | "'" { let l = char_literal [] lexbuf in + | "'" { let l = char_literal lexbuf.lex_start_p [] lexbuf in CONSTANT (Cabs.CONST_CHAR(false, l), currentLoc lexbuf) } - | "L'" { let l = char_literal [] lexbuf in + | "L'" { let l = char_literal lexbuf.lex_start_p [] lexbuf in CONSTANT (Cabs.CONST_CHAR(true, l), currentLoc lexbuf) } - | "\"" { let l = string_literal [] lexbuf in + | "\"" { let l = string_literal lexbuf.lex_start_p [] lexbuf in STRING_LITERAL(false, l, currentLoc lexbuf) } - | "L\"" { let l = string_literal [] lexbuf in + | "L\"" { let l = string_literal lexbuf.lex_start_p [] lexbuf in STRING_LITERAL(true, l, currentLoc lexbuf) } | "..." { ELLIPSIS(currentLoc lexbuf) } | "+=" { ADD_ASSIGN(currentLoc lexbuf) } @@ -376,15 +376,17 @@ and char = parse | _ as c { Int64.of_int (Char.code c) } -and char_literal accu = parse - | '\'' { List.rev accu } +and char_literal startp accu = parse + | '\'' { lexbuf.lex_start_p <- startp; + List.rev accu } | '\n' | eof { fatal_error lexbuf "missing terminating \"'\" character" } - | "" { let c = char lexbuf in char_literal (c :: accu) lexbuf } + | "" { let c = char lexbuf in char_literal startp (c :: accu) lexbuf } -and string_literal accu = parse - | '\"' { List.rev accu } +and string_literal startp accu = parse + | '\"' { lexbuf.lex_start_p <- startp; + List.rev accu } | '\n' | eof { fatal_error lexbuf "missing terminating '\"' character" } - | "" { let c = char lexbuf in string_literal (c :: accu) lexbuf } + | "" { let c = char lexbuf in string_literal startp (c :: accu) lexbuf } (* We assume gcc -E syntax but try to tolerate variations. *) and hash = parse -- cgit From 1ea7d1d09c350d0f0613f0bd763c3e01a70ddbb9 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 09:57:02 +0200 Subject: Distinguish [MENHIR] and [MENHIR_MODE]. Cleaner, more flexible. --- Makefile.menhir | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile.menhir b/Makefile.menhir index 72b54b14..db28ffaa 100644 --- a/Makefile.menhir +++ b/Makefile.menhir @@ -1,5 +1,9 @@ # This is a Makefile fragment for Menhir-specific aspects. +# Executable. + +MENHIR = menhir + # This flag can be set to true or false. It controls whether we use # Menhir's table back-end or code back-end. The table back-end is a # bit slower, but supports more features, including advanced error @@ -7,12 +11,12 @@ MENHIR_TABLE = false -# Executable. +# To pass or not to pass --table. ifeq ($(MENHIR_TABLE),true) - MENHIR = menhir --table + MENHIR_MODE = --table else - MENHIR = menhir + MENHIR_MODE = endif # Options. @@ -30,7 +34,7 @@ endif # The compilation rule. %.ml %.mli: %.mly - $(MENHIR) $(MENHIR_FLAGS) $< + $(MENHIR) $(MENHIR_MODE) $(MENHIR_FLAGS) $< # Note 1: finding where MenhirLib has been installed would be easier if we # could depend on ocamlfind, but as far as I understand and as of today, @@ -50,7 +54,7 @@ endif ifeq ($(MENHIR_TABLE),true) - MENHIR_SUGGESTION = $(MENHIR) --suggest-comp-flags + MENHIR_SUGGESTION = $(MENHIR) $(MENHIR_MODE) --suggest-comp-flags MENHIR_INCLUDES := $(shell \ if $(MENHIR_SUGGESTION) | grep -e "-package" >/dev/null ; then \ -- cgit From ed549acd7d71d274c7e39480900b14d1b65c3cd1 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 09:59:07 +0200 Subject: Switch to --table mode. This is slightly slower but otherwise changes nothing. --- Makefile.menhir | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.menhir b/Makefile.menhir index db28ffaa..82f44e5f 100644 --- a/Makefile.menhir +++ b/Makefile.menhir @@ -9,7 +9,7 @@ MENHIR = menhir # bit slower, but supports more features, including advanced error # reporting. -MENHIR_TABLE = false +MENHIR_TABLE = true # To pass or not to pass --table. -- cgit From e036d68cb41de1ddac47d7686d25904281405ffe Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 11:19:36 +0200 Subject: Makefile.extr: [make clean] removes .automaton files. --- Makefile.extr | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.extr b/Makefile.extr index 6c19d1ed..6a03f1e1 100644 --- a/Makefile.extr +++ b/Makefile.extr @@ -160,6 +160,7 @@ clean: rm -f $(EXECUTABLES) rm -f $(GENERATED) for d in $(ALLDIRS); do rm -f $$d/*.cm[iox] $$d/*.o; done + rm -f cparser/pre_parser.automaton backend/CMparser.automaton # Generation of .depend.extr -- cgit From 03f39523094fd41c8aad5ee7a8169ffc448cfd4a Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 16 Oct 2015 17:56:06 +0200 Subject: Read the whole source C file into memory instad of reading it on demand. Having the file in memory will help build an error message. Also, this may be slightly faster. --- cparser/Lexer.mll | 4 ++-- cparser/Parse.ml | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index 6be59aa8..aca1be27 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -440,7 +440,7 @@ and singleline_comment = parse open Parser open Aut.GramDefs - let tokens_stream filename channel : token coq_Stream = + let tokens_stream filename text : token coq_Stream = let tokens = Queue.create () in let lexer_wraper lexbuf : Pre_parser.token = let res = @@ -452,7 +452,7 @@ and singleline_comment = parse Queue.push res tokens; res in - let lexbuf = Lexing.from_channel channel in + let lexbuf = Lexing.from_string text in lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname = filename; pos_lnum = 1}; contexts_stk := [init_ctx]; Pre_parser.translation_unit_file lexer_wraper lexbuf; diff --git a/cparser/Parse.ml b/cparser/Parse.ml index cfa95688..1d92d5a5 100644 --- a/cparser/Parse.ml +++ b/cparser/Parse.ml @@ -38,9 +38,22 @@ let parse_transformations s = s; !t +let read_file sourcefile = + let ic = open_in sourcefile in + let n = in_channel_length ic in + let text = really_input_string ic n in + close_in ic; + text + let preprocessed_file transfs name sourcefile = Cerrors.reset(); - let ic = open_in sourcefile in + (* Reading the whole file at once may seem costly, but seems to be + the simplest / most robust way of accessing the text underlying + a range of positions. This is used when printing an error message. + Plus, I note that reading the whole file into memory leads to a + speed increase: "make -C test" speeds up by 3 seconds out of 40 + on my machine. *) + let text = read_file sourcefile in let p = try let t = parse_transformations transfs in @@ -52,7 +65,7 @@ let preprocessed_file transfs name sourcefile = parsing of the entire file. This is non-negligeabe, so we cannot use Timing.time2 *) (fun () -> - Parser.translation_unit_file inf (Lexer.tokens_stream name ic)) () + Parser.translation_unit_file inf (Lexer.tokens_stream name text)) () with | Parser.Parser.Inter.Fail_pr -> (* Theoretically impossible : implies inconsistencies @@ -65,5 +78,4 @@ let preprocessed_file transfs name sourcefile = with | Cerrors.Abort -> [] in - close_in ic; if Cerrors.check_errors() then None else Some p -- cgit From c0643d38d5b26d707e85f7dd930d1dea2256872f Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 11:34:06 +0200 Subject: A .gitignore entry. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 32cbdadf..296dac75 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ cparser/Lexer.ml cparser/pre_parser.ml cparser/pre_parser.mli cparser/pre_parser.automaton +backend/CMparser.automaton lib/Readconfig.ml lib/Tokenize.ml driver/Version.ml -- cgit From 026c78ba5bce18516268b47b3bcd2c19142544dc Mon Sep 17 00:00:00 2001 From: François Pottier Date: Tue, 20 Oct 2015 21:58:03 +0200 Subject: Added [Cerrors.fatal_error_raw]. --- cparser/Cerrors.ml | 12 ++++++++++++ cparser/Cerrors.mli | 1 + 2 files changed, 13 insertions(+) diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml index 23ec1710..5c077f37 100644 --- a/cparser/Cerrors.ml +++ b/cparser/Cerrors.ml @@ -26,6 +26,18 @@ let reset () = num_errors := 0; num_warnings := 0 exception Abort +(* [fatal_error_raw] is identical to [fatal_error], except it uses [Printf] + to print its message, as opposed to [Format], and does not automatically + introduce indentation and a final dot into the message. This is useful + for multi-line messages. *) + +let fatal_error_raw fmt = + incr num_errors; + Printf.kfprintf + (fun _ -> raise Abort) + stderr + (fmt ^^ "Fatal error; compilation aborted.\n%!") + let fatal_error fmt = incr num_errors; kfprintf diff --git a/cparser/Cerrors.mli b/cparser/Cerrors.mli index 6d34451b..3e315fad 100644 --- a/cparser/Cerrors.mli +++ b/cparser/Cerrors.mli @@ -16,6 +16,7 @@ val warn_error : bool ref val reset : unit -> unit exception Abort +val fatal_error_raw : ('a, out_channel, unit, 'b) format4 -> 'a val fatal_error : ('a, Format.formatter, unit, unit, unit, 'b) format6 -> 'a val error : ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a val warning : ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a -- cgit From abf35973bb7128689b94a0e518cc50d26c4d5e10 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 11:44:52 +0200 Subject: Remove all productions that involve the [error] token. 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. --- cparser/pre_parser.mly | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 52a94078..23ef1bc5 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -25,16 +25,6 @@ let declare_typename (i,_,_) = !declare_typename i - let syntax_error pos = - Cerrors.fatal_error "%s:%d: syntax error" - pos.Lexing.pos_fname pos.Lexing.pos_lnum - - let unclosed opening closing pos1 pos2 = - Cerrors.info "%s:%d: syntax error: expecting '%s'" - pos2.Lexing.pos_fname pos2.Lexing.pos_lnum closing; - Cerrors.fatal_error "%s:%d: this is the location of the unclosed '%s'" - pos1.Lexing.pos_fname pos1.Lexing.pos_lnum opening - %} %token @@ -163,30 +153,18 @@ primary_expression: | string_literals_list | LPAREN expression RPAREN {} -| LPAREN expression error - { unclosed "(" ")" $startpos($1) $endpos } postfix_expression: | primary_expression | postfix_expression LBRACK expression RBRACK | postfix_expression LPAREN argument_expression_list? RPAREN - {} -| postfix_expression LPAREN argument_expression_list? error - { unclosed "(" ")" $startpos($2) $endpos } | BUILTIN_VA_ARG LPAREN assignment_expression COMMA type_name RPAREN - {} -| BUILTIN_VA_ARG LPAREN assignment_expression COMMA type_name error - { unclosed "(" ")" $startpos($2) $endpos } | postfix_expression DOT other_identifier | postfix_expression PTR other_identifier | postfix_expression INC | postfix_expression DEC | LPAREN type_name RPAREN LBRACE initializer_list COMMA? RBRACE {} -| LPAREN type_name error - { unclosed "(" ")" $startpos($1) $endpos } -| LPAREN type_name RPAREN LBRACE initializer_list COMMA? error - { unclosed "{" "}" $startpos($4) $endpos } argument_expression_list: | assignment_expression @@ -425,8 +403,6 @@ struct_or_union_specifier: | struct_or_union attribute_specifier_list other_identifier? LBRACE struct_declaration_list RBRACE | struct_or_union attribute_specifier_list other_identifier {} -| struct_or_union attribute_specifier_list other_identifier? LBRACE struct_declaration_list error - { unclosed "{" "}" $startpos($4) $endpos } struct_or_union: | STRUCT @@ -468,8 +444,6 @@ enum_specifier: | ENUM attribute_specifier_list other_identifier? LBRACE enumerator_list COMMA? RBRACE | ENUM attribute_specifier_list other_identifier {} -| ENUM attribute_specifier_list other_identifier? LBRACE enumerator_list COMMA? error - { unclosed "{" "}" $startpos($4) $endpos } enumerator_list: | declare_varname(enumerator) @@ -598,8 +572,6 @@ c_initializer: | assignment_expression | LBRACE initializer_list COMMA? RBRACE {} -| LBRACE initializer_list COMMA? error - { unclosed "{" "}" $startpos($1) $endpos } initializer_list: | designation? c_initializer @@ -677,8 +649,6 @@ labeled_statement(last_statement): compound_statement(openc): | LBRACE openc block_item_list? close_context RBRACE {} -| LBRACE openc block_item_list? close_context error - { unclosed "{" "}" $startpos($1) $endpos } block_item_list: | block_item_list? block_item @@ -820,8 +790,6 @@ translation_unit_file: | translation_unit EOF | EOF {} -| error - { syntax_error $endpos } translation_unit: | external_declaration @@ -866,5 +834,3 @@ declaration_list: function_definition: | function_definition_begin LBRACE block_item_list? close_context RBRACE {} -| function_definition_begin LBRACE block_item_list? close_context error - { unclosed "{" "}" $startpos($2) $endpos } -- cgit From 431d01db20514292c75fa00f522a8b56d7150b03 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Wed, 7 Oct 2015 13:22:25 +0200 Subject: A general comment about phantom parameters. --- cparser/pre_parser.mly | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 23ef1bc5..df0244b7 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -145,6 +145,22 @@ declare_varname(nt): declare_typename(nt): i = nt { declare_typename i; i } +(* A note about phantom parameters. The definition of a non-terminal symbol + [nt] is sometimes parameterized with a parameter that is unused in the + right-hand side. This parameter disappears when macro-expansion takes + place. Thus, the presence of this parameter does not influence the language + that is accepted by the parser. Yet, it carries information about the + context, since different call sites can supply different values of this + parameter. This forces the creation of two (or more) identical copies of + the definition of [nt], which leads to a larger automaton, where some + states have been duplicated. In these states, more information about the + context is available, which allows better syntax error messages to be + given. + + By convention, a formal phantom parameter is named [phantom], so as to be + easily recognizable. For clarity, we usually explicitly document which + actual values it can take. *) + (* Actual grammar *) primary_expression: -- cgit From 89e9eabc2fb752a6535cb375232d0141cc1f4fd3 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Wed, 7 Oct 2015 13:26:38 +0200 Subject: Added a phantom parameter to [specifier_qualifier_list]. --- cparser/pre_parser.mly | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index df0244b7..1940aaa8 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -431,12 +431,13 @@ struct_declaration_list: {} struct_declaration: -| specifier_qualifier_list struct_declarator_list? SEMICOLON +| specifier_qualifier_list(struct_declaration) struct_declarator_list? SEMICOLON {} (* As in the standard, except it also encodes the constraint described in the comment above [declaration_specifiers]. *) -specifier_qualifier_list: +(* The phantom parameter can be [struct_declaration] or [type_name]. *) +specifier_qualifier_list(phantom): | type_qualifier_list? TYPEDEF_NAME type_qualifier_list? | type_qualifier_list? type_specifier_no_typedef_name specifier_qualifier_list_no_typedef_name? {} @@ -570,7 +571,7 @@ parameter_declaration: { None } type_name: -| specifier_qualifier_list abstract_declarator? +| specifier_qualifier_list(type_name) abstract_declarator? {} abstract_declarator: -- cgit From e9ae100975a868a6e0e91a51ce54d243d52ab6c7 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 12:47:41 +0200 Subject: Added a phantom parameter to [abstract_declarator]. 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. --- cparser/pre_parser.mly | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 1940aaa8..8002d5c4 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -567,20 +567,24 @@ parameter_list: parameter_declaration: | declaration_specifiers id=declare_varname(fst(declarator)) { Some id } -| declaration_specifiers abstract_declarator? +| declaration_specifiers abstract_declarator(parameter_declaration)? { None } type_name: -| specifier_qualifier_list(type_name) abstract_declarator? +| specifier_qualifier_list(type_name) abstract_declarator(type_name)? {} -abstract_declarator: +(* The phantom parameter can be [parameter_declaration] or [type_name]. + We take the latter to mean [type_or_name] or [direct_abstract_declarator]. + We need not distinguish these two cases: in both cases, a closing parenthesis + is permitted (and we do not wish to keep track of why it is permitted). *) +abstract_declarator(phantom): | pointer | ioption(pointer) direct_abstract_declarator {} direct_abstract_declarator: -| LPAREN abstract_declarator RPAREN +| LPAREN abstract_declarator(type_name) RPAREN | direct_abstract_declarator? LBRACK type_qualifier_list? optional(assignment_expression, RBRACK) | ioption(direct_abstract_declarator) LPAREN in_context(parameter_type_list?) RPAREN {} -- cgit From b371ea255077d700f848165a5834f104601e8253 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Wed, 7 Oct 2015 15:43:52 +0200 Subject: Added a phantom parameter to [declaration_specifiers]. 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. --- cparser/pre_parser.mly | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 8002d5c4..0bbf10ca 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -319,8 +319,8 @@ constant_expression: typedef). *) declaration: -| declaration_specifiers init_declarator_list? SEMICOLON -| declaration_specifiers_typedef typedef_declarator_list? SEMICOLON +| declaration_specifiers(declaration) init_declarator_list? SEMICOLON +| declaration_specifiers_typedef typedef_declarator_list? SEMICOLON {} init_declarator_list: @@ -384,7 +384,11 @@ declaration_specifiers_no_typedef_name: The first field is a named t, while the second is unnamed of type t. *) -declaration_specifiers: +(* The phantom parameter is EITHER [declaration], which we take to mean that + this is the beginning of a declaration *or* a function definition (we + cannot distinguish the two!), OR [parameter_declaration], which means that + this is the beginning of a parameter declaration. *) +declaration_specifiers(phantom): | ioption(declaration_specifiers_no_type) TYPEDEF_NAME declaration_specifiers_no_type? | declaration_specifiers_no_type? type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? {} @@ -565,9 +569,9 @@ parameter_list: { i::l } parameter_declaration: -| declaration_specifiers id=declare_varname(fst(declarator)) +| declaration_specifiers(parameter_declaration) id=declare_varname(fst(declarator)) { Some id } -| declaration_specifiers abstract_declarator(parameter_declaration)? +| declaration_specifiers(parameter_declaration) abstract_declarator(parameter_declaration)? { None } type_name: @@ -826,12 +830,12 @@ external_declaration: {} function_definition_begin: -| declaration_specifiers ioption(pointer) x=direct_declarator +| declaration_specifiers(declaration) ioption(pointer) x=direct_declarator { match x with | (_, None) -> $syntaxerror | (i, Some restore_fun) -> restore_fun () } -| declaration_specifiers ioption(pointer) x=direct_declarator +| declaration_specifiers(declaration) ioption(pointer) x=direct_declarator LPAREN params=identifier_list RPAREN open_context declaration_list { match x with | (_, Some _) -> $syntaxerror -- cgit From 17733e430b0c0a19853e1367ca38282a943e0c76 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Wed, 7 Oct 2015 17:10:29 +0200 Subject: Added a phantom parameter to [declaration]. 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. --- cparser/pre_parser.mly | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 0bbf10ca..78641e58 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -318,9 +318,12 @@ constant_expression: cannot contain an initialization (this is an error to initialize a typedef). *) -declaration: -| declaration_specifiers(declaration) init_declarator_list? SEMICOLON -| declaration_specifiers_typedef typedef_declarator_list? SEMICOLON +(* The phantom parameter is either [block_item], which means we are + definitely reading a declaration, or [external_declaration], which + means we could also be reading the beginning of a function definition. *) +declaration(phantom): +| declaration_specifiers(declaration(phantom)) init_declarator_list? SEMICOLON +| declaration_specifiers_typedef typedef_declarator_list? SEMICOLON {} init_declarator_list: @@ -384,10 +387,10 @@ declaration_specifiers_no_typedef_name: The first field is a named t, while the second is unnamed of type t. *) -(* The phantom parameter is EITHER [declaration], which we take to mean that - this is the beginning of a declaration *or* a function definition (we - cannot distinguish the two!), OR [parameter_declaration], which means that - this is the beginning of a parameter declaration. *) +(* The phantom parameter is either [declaration(_)], which means that + this is the beginning of a declaration or a function definition, or + [parameter_declaration], which means that this is the beginning of a + parameter declaration. *) declaration_specifiers(phantom): | ioption(declaration_specifiers_no_type) TYPEDEF_NAME declaration_specifiers_no_type? | declaration_specifiers_no_type? type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? @@ -680,7 +683,7 @@ block_item_list: {} block_item: -| declaration +| declaration(block_item) | statement_finish_noclose | PRAGMA {} @@ -771,7 +774,7 @@ iteration_statement(openc,last_statement): for_statement_header: | optional(expression, SEMICOLON) -| declaration +| declaration(block_item) {} asm_attributes: @@ -825,17 +828,19 @@ translation_unit: external_declaration: | function_definition -| declaration +| declaration(external_declaration) | PRAGMA {} function_definition_begin: -| declaration_specifiers(declaration) ioption(pointer) x=direct_declarator +| declaration_specifiers(declaration(external_declaration)) + ioption(pointer) x=direct_declarator { match x with | (_, None) -> $syntaxerror | (i, Some restore_fun) -> restore_fun () } -| declaration_specifiers(declaration) ioption(pointer) x=direct_declarator +| declaration_specifiers(declaration(external_declaration)) + ioption(pointer) x=direct_declarator LPAREN params=identifier_list RPAREN open_context declaration_list { match x with | (_, Some _) -> $syntaxerror @@ -853,7 +858,7 @@ identifier_list: declaration_list: | /*empty*/ {} -| declaration_list declaration +| declaration_list declaration(block_item) {} function_definition: -- cgit From 44b910bb829f6e5920b0a51985624c345019711e Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 8 Oct 2015 01:20:31 +0200 Subject: Factorized [declaration_specifier_no_type]. This saves a few states. --- cparser/pre_parser.mly | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 78641e58..0aa884c9 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -354,10 +354,14 @@ storage_class_specifier_no_typedef: (* [declaration_specifiers_no_type] matches declaration specifiers that do not contain either "typedef" nor type specifiers. *) +declaration_specifier_no_type: +| storage_class_specifier_no_typedef +| type_qualifier +| function_specifier + {} + declaration_specifiers_no_type: -| storage_class_specifier_no_typedef declaration_specifiers_no_type? -| type_qualifier declaration_specifiers_no_type? -| function_specifier declaration_specifiers_no_type? +| declaration_specifier_no_type declaration_specifiers_no_type? {} (* [declaration_specifiers_no_typedef_name] matches declaration -- cgit From 4972a6a8851dfe823a022fc3b8c7c01332a89c35 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 8 Oct 2015 01:30:18 +0200 Subject: Introduced [list] and [ilist]. Redefined [declaration_specifiers_no_type] as a left-recursive list. This further reduces the number of states (and error states). --- cparser/pre_parser.mly | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 0aa884c9..e2ca8439 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -95,6 +95,21 @@ option(X): optional(X, Y): ioption(X) Y {} +(* This is a standard left-recursive, possibly empty list, without + separators. Note that, by convention, [X*] is syntactic sugar for + [list(X)]. *) + +list(X): +| (* empty *) {} +| list(X) X {} + +(* [ilist(X)] is equivalent to [list(X)], but is marked [%inline], + so its definition is expanded. *) + +%inline ilist(X): +| (* empty *) {} +| list(X) X {} + %inline fst(X): | x = X { fst x } @@ -352,7 +367,7 @@ storage_class_specifier_no_typedef: | REGISTER {} -(* [declaration_specifiers_no_type] matches declaration specifiers +(* [declaration_specifier_no_type] matches declaration specifiers that do not contain either "typedef" nor type specifiers. *) declaration_specifier_no_type: | storage_class_specifier_no_typedef @@ -360,10 +375,6 @@ declaration_specifier_no_type: | function_specifier {} -declaration_specifiers_no_type: -| declaration_specifier_no_type declaration_specifiers_no_type? - {} - (* [declaration_specifiers_no_typedef_name] matches declaration specifiers that contain neither "typedef" nor a typedef name (i.e. type specifier declared using a previous "typedef @@ -396,18 +407,18 @@ declaration_specifiers_no_typedef_name: [parameter_declaration], which means that this is the beginning of a parameter declaration. *) declaration_specifiers(phantom): -| ioption(declaration_specifiers_no_type) TYPEDEF_NAME declaration_specifiers_no_type? -| declaration_specifiers_no_type? type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? +| ilist(declaration_specifier_no_type) TYPEDEF_NAME declaration_specifier_no_type* +| declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? {} (* This matches declaration_specifiers that do contains once the "typedef" keyword. To avoid conflicts, we also encode the constraint described in the comment for [declaration_specifiers]. *) declaration_specifiers_typedef: -| declaration_specifiers_no_type? TYPEDEF declaration_specifiers_no_type? TYPEDEF_NAME declaration_specifiers_no_type? -| ioption(declaration_specifiers_no_type) TYPEDEF_NAME declaration_specifiers_no_type? TYPEDEF declaration_specifiers_no_type? -| declaration_specifiers_no_type? TYPEDEF declaration_specifiers_no_type? type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? -| declaration_specifiers_no_type? type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? TYPEDEF declaration_specifiers_no_typedef_name? +| declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* TYPEDEF_NAME declaration_specifier_no_type* +| ilist(declaration_specifier_no_type) TYPEDEF_NAME declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* +| declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? +| declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? TYPEDEF declaration_specifiers_no_typedef_name? {} (* A type specifier which is not a typedef name. *) -- cgit From 1c6d12874f0737d07acbda6b56e43053ca159c36 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 8 Oct 2015 09:23:41 +0200 Subject: Reformulated the definitions of [option] and [list] in a slightly more elegant manner. --- cparser/pre_parser.mly | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index e2ca8439..6627568d 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -68,12 +68,6 @@ so this definition of [option] is actually used, even though the word [option] does not appear in the rest of this file. *) -option(X): -| /* nothing */ - { None } -| x = X - { Some x } - (* [ioption(X)] is equivalent to [option(X)], but is marked [%inline], so its definition is expanded. In the absence of conflicts, the two are equivalent. Using [ioption] instead of [option] in well-chosen @@ -81,12 +75,20 @@ option(X): of [ioption] in well-chosen places can help reduce the number of states of the automaton. *) +(* Defining the non-%inline version in terms of the %inline version is + a standard idiom. It obviates the need to duplicate the definition. + The same idiom is used elsewhere below. *) + %inline ioption(X): | /* nothing */ { None } | x = X { Some x } +option(X): + o = ioption(X) + { o } + (* [optional(X, Y)] is equivalent to [X? Y]. However, by inlining the two possibilies -- either [X Y] or just [Y] -- we are able to give more meaningful syntax error messages. [optional(X, Y)] @@ -99,17 +101,17 @@ optional(X, Y): separators. Note that, by convention, [X*] is syntactic sugar for [list(X)]. *) -list(X): -| (* empty *) {} -| list(X) X {} - (* [ilist(X)] is equivalent to [list(X)], but is marked [%inline], - so its definition is expanded. *) + so its definition is expanded (only one level deep, of course). *) %inline ilist(X): | (* empty *) {} | list(X) X {} +list(X): + xs = ilist(X) + { xs } + %inline fst(X): | x = X { fst x } -- cgit From ca5594ace000eebab2e89791aa42cb849fad1a16 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 8 Oct 2015 10:09:20 +0200 Subject: Factorized [declaration_specifier_no_typedef_name]. This results in slightly fewer states. --- cparser/pre_parser.mly | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 6627568d..f25dde4f 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -377,15 +377,19 @@ declaration_specifier_no_type: | function_specifier {} -(* [declaration_specifiers_no_typedef_name] matches declaration +(* [declaration_specifier_no_typedef_name] matches declaration specifiers that contain neither "typedef" nor a typedef name (i.e. type specifier declared using a previous "typedef keyword"). *) +declaration_specifier_no_typedef_name: +| storage_class_specifier_no_typedef +| type_qualifier +| function_specifier +| type_specifier_no_typedef_name + {} + declaration_specifiers_no_typedef_name: -| storage_class_specifier_no_typedef declaration_specifiers_no_typedef_name? -| type_qualifier declaration_specifiers_no_typedef_name? -| function_specifier declaration_specifiers_no_typedef_name? -| type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? + declaration_specifier_no_typedef_name declaration_specifiers_no_typedef_name? {} (* [declaration_specifiers_no_type] matches declaration_specifiers -- cgit From d7d088921bcd26012bd27e5cc4f01746f91d029b Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 8 Oct 2015 10:16:25 +0200 Subject: Replaced [declaration_specifiers_no_typedef_name] with [declaration_specifier_no_typedef_name*]. This replaces a right-recursive list with a left-recursive list. This saves 2 states and 6 error states. --- cparser/pre_parser.mly | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index f25dde4f..f077a30c 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -388,10 +388,6 @@ declaration_specifier_no_typedef_name: | type_specifier_no_typedef_name {} -declaration_specifiers_no_typedef_name: - declaration_specifier_no_typedef_name declaration_specifiers_no_typedef_name? - {} - (* [declaration_specifiers_no_type] matches declaration_specifiers that do not contains "typedef". Moreover, it makes sure that it contains either one typename and not other type specifier or no @@ -414,7 +410,7 @@ declaration_specifiers_no_typedef_name: parameter declaration. *) declaration_specifiers(phantom): | ilist(declaration_specifier_no_type) TYPEDEF_NAME declaration_specifier_no_type* -| declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? +| declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifier_no_typedef_name* {} (* This matches declaration_specifiers that do contains once the @@ -423,8 +419,8 @@ declaration_specifiers(phantom): declaration_specifiers_typedef: | declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* TYPEDEF_NAME declaration_specifier_no_type* | ilist(declaration_specifier_no_type) TYPEDEF_NAME declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* -| declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? -| declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifiers_no_typedef_name? TYPEDEF declaration_specifiers_no_typedef_name? +| declaration_specifier_no_type* TYPEDEF declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifier_no_typedef_name* +| declaration_specifier_no_type* type_specifier_no_typedef_name declaration_specifier_no_typedef_name* TYPEDEF declaration_specifier_no_typedef_name* {} (* A type specifier which is not a typedef name. *) -- cgit From c6d574de8b0435676947b6b7e97d6d36d89f1f20 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Thu, 8 Oct 2015 11:03:30 +0200 Subject: Redefined [pointer] as a left-recursive list. 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. --- cparser/pre_parser.mly | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index f077a30c..61fd6972 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -552,7 +552,7 @@ function_specifier: has to be restored if entering the body of the function being defined, if so. *) declarator: -| ioption(pointer) x = direct_declarator attribute_specifier_list +| ilist(pointer1) x = direct_declarator attribute_specifier_list { x } direct_declarator: @@ -568,9 +568,26 @@ direct_declarator: | None -> (fst x, Some restore_fun) | Some _ -> x } -pointer: -| STAR type_qualifier_list? -| STAR type_qualifier_list? pointer +(* The C standard defines [pointer] as a right-recursive list. We prefer to + define it as a left-recursive list, because this provides better static + context (that is, this changes the automaton in such a way that it is + easier to give good error messages, in at least 2 states). + + The non-terminal symbol [pointer1] represents one list element. + + [pointer], which represents a non-empty list of [pointer1]'s, is defined + as [pointer1* pointer1]. + + When the C standard writes [pointer?], which represents a possibly empty + list of [pointer1]'s, we write [pointer1*] or [ilist(pointer1)]. The two + are equivalent, as long as there is no conflict. *) + +%inline pointer1: + STAR type_qualifier_list? + {} + +%inline pointer: + pointer1* pointer1 {} type_qualifier_list: @@ -604,7 +621,7 @@ type_name: is permitted (and we do not wish to keep track of why it is permitted). *) abstract_declarator(phantom): | pointer -| ioption(pointer) direct_abstract_declarator +| ilist(pointer1) direct_abstract_declarator {} direct_abstract_declarator: @@ -851,13 +868,13 @@ external_declaration: function_definition_begin: | declaration_specifiers(declaration(external_declaration)) - ioption(pointer) x=direct_declarator + ilist(pointer1) x=direct_declarator { match x with | (_, None) -> $syntaxerror | (i, Some restore_fun) -> restore_fun () } | declaration_specifiers(declaration(external_declaration)) - ioption(pointer) x=direct_declarator + ilist(pointer1) x=direct_declarator LPAREN params=identifier_list RPAREN open_context declaration_list { match x with | (_, Some _) -> $syntaxerror -- cgit From 4a088ba7c9f82d105b25935c1ff7abb07e72de6b Mon Sep 17 00:00:00 2001 From: François Pottier Date: Mon, 19 Oct 2015 10:59:28 +0200 Subject: Reformulated [specifier_qualifier_list_no_typedef_name] as a left-recursive list. This saves 7 states and 4 error states. --- cparser/pre_parser.mly | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 61fd6972..639c5ac5 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -463,12 +463,12 @@ struct_declaration: (* The phantom parameter can be [struct_declaration] or [type_name]. *) specifier_qualifier_list(phantom): | type_qualifier_list? TYPEDEF_NAME type_qualifier_list? -| type_qualifier_list? type_specifier_no_typedef_name specifier_qualifier_list_no_typedef_name? +| type_qualifier_list? type_specifier_no_typedef_name specifier_qualifier_no_typedef_name* {} -specifier_qualifier_list_no_typedef_name: -| type_specifier_no_typedef_name specifier_qualifier_list_no_typedef_name? -| type_qualifier specifier_qualifier_list_no_typedef_name? +specifier_qualifier_no_typedef_name: +| type_specifier_no_typedef_name +| type_qualifier {} struct_declarator_list: -- cgit From e9ea9da494eeabfc459e7ba43f9f5ccb9a48dcf1 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Mon, 19 Oct 2015 18:39:27 +0200 Subject: Inlined [constant_expression] to save one state. --- cparser/pre_parser.mly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 639c5ac5..f3bfb9e8 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -323,7 +323,7 @@ expression: | expression COMMA assignment_expression {} -constant_expression: +%inline constant_expression: | conditional_expression {} -- cgit From e5d2a949f0e5cd5f1ddaece41a03f65ac1e3836e Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 12:59:47 +0200 Subject: Removed the two uses of $syntaxerror in a semantic action. 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). --- cparser/pre_parser.mly | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index f3bfb9e8..96cf0de7 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -870,14 +870,19 @@ function_definition_begin: | declaration_specifiers(declaration(external_declaration)) ilist(pointer1) x=direct_declarator { match x with - | (_, None) -> $syntaxerror + | (_, None) -> !open_context() + (* this case does not make sense, but we let it pass anyway; + this error will be caught later on by a type check *) | (i, Some restore_fun) -> restore_fun () } | declaration_specifiers(declaration(external_declaration)) ilist(pointer1) x=direct_declarator LPAREN params=identifier_list RPAREN open_context declaration_list { match x with - | (_, Some _) -> $syntaxerror + | (i, Some _) -> declare_varname i + (* this case does not make sense; the syntax of K&R + declarators is broken anyway, Jacques-Henri should + propose a fix soon *) | (i, None) -> declare_varname i; List.iter declare_varname params -- cgit From 073e50a2b795f68e59075d6e365e72b4bd2417c1 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:01:14 +0200 Subject: Changed [asm_flags] to a left-recursive list. This allows us to give a better error message in one state. --- cparser/pre_parser.mly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 96cf0de7..e55389ba 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -845,7 +845,7 @@ asm_op_name: asm_flags: | string_literals_list -| string_literals_list COMMA asm_flags +| asm_flags COMMA string_literals_list {} translation_unit_file: -- cgit From 883ebf950a4ef38788792cb1129fb9c408225ad3 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:04:34 +0200 Subject: Added an %on_error_reduce declaration. This affects in which states errors are detected, but does not change the language that is accepted. --- cparser/pre_parser.mly | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index e55389ba..1de726be 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -60,6 +60,48 @@ %nonassoc highPrec %start translation_unit_file + +(* The following declarations cause certain nonterminal symbols to be + reduced when an error is detected. This replaces error actions in + the automaton with reduction actions. So, if the input is correct, + this makes no difference, and if the input is incorrect, this only + forces a few more reductions to take place before the error is + detected and reported. If used properly, this facilitates error + reports. *) + +%on_error_reduce + primary_expression + postfix_expression + unary_expression + cast_expression + multiplicative_expression + additive_expression + shift_expression + relational_expression + equality_expression + and_expression + exclusive_or_expression + inclusive_or_expression + logical_and_expression + logical_or_expression + conditional_expression + assignment_expression + expression + attribute_specifier_list + declarator + statement_finish_close + iteration_statement(nop,statement_finish_close) + enum_specifier + struct_or_union_specifier + specifier_qualifier_list(struct_declaration) + specifier_qualifier_list(type_name) + option(abstract_declarator(type_name)) + abstract_declarator(type_name) + abstract_declarator(parameter_declaration) + asm_flags + asm_operands + init_declarator + %% (* Helpers *) -- cgit From 8fee5abd0a1d0865d3d3d4b4de48aacb4be0914e Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:08:56 +0200 Subject: Lexer cleanup: isolate the entry point into the lexer. --- cparser/Lexer.mll | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index aca1be27..c453b15b 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -440,15 +440,19 @@ and singleline_comment = parse open Parser open Aut.GramDefs + (* This is the main entry point to the lexer. *) + + let lexer : lexbuf -> Pre_parser.token = + fun lexbuf -> + if lexbuf.lex_curr_p.pos_cnum = lexbuf.lex_curr_p.pos_bol then + initial_linebegin lexbuf + else + initial lexbuf + let tokens_stream filename text : token coq_Stream = let tokens = Queue.create () in let lexer_wraper lexbuf : Pre_parser.token = - let res = - if lexbuf.lex_curr_p.pos_cnum = lexbuf.lex_curr_p.pos_bol then - initial_linebegin lexbuf - else - initial lexbuf - in + let res = lexer lexbuf in Queue.push res tokens; res in -- cgit From dca619cc34e64e63fe36ec9b5acdb42aafe665a8 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:11:23 +0200 Subject: Lexer cleanup: isolate [lexer_wraper] and rename it to [lexer]. --- cparser/Lexer.mll | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index c453b15b..ab4e03fe 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -449,17 +449,21 @@ and singleline_comment = parse else initial lexbuf + (* [lexer tokens buffer] is a new lexer, which wraps [lexer], and also + records the token stream into the FIFO queue [tokens]. *) + + let lexer tokens : lexbuf -> Pre_parser.token = + fun lexbuf -> + let token = lexer lexbuf in + Queue.push token tokens; + token + let tokens_stream filename text : token coq_Stream = let tokens = Queue.create () in - let lexer_wraper lexbuf : Pre_parser.token = - let res = lexer lexbuf in - Queue.push res tokens; - res - in let lexbuf = Lexing.from_string text in lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname = filename; pos_lnum = 1}; contexts_stk := [init_ctx]; - Pre_parser.translation_unit_file lexer_wraper lexbuf; + Pre_parser.translation_unit_file (lexer tokens) lexbuf; assert (List.length !contexts_stk = 1); let rec compute_token_stream () = let loop t v = -- cgit From 8d1a15f7f5c8fbea194a67c49c5aa10d6371b267 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:16:35 +0200 Subject: Lexer update: use Menhir's incremental API instead of Menhir's traditional API. 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". --- cparser/Lexer.mll | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index ab4e03fe..62764a48 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -458,12 +458,25 @@ and singleline_comment = parse Queue.push token tokens; token - let tokens_stream filename text : token coq_Stream = - let tokens = Queue.create () in + (* [invoke_pre_parser] is in charge of calling the pre_parser. It uses + the incremental API, which allows us to do our own error handling. *) + + let invoke_pre_parser filename text lexer = let lexbuf = Lexing.from_string text in lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname = filename; pos_lnum = 1}; + let module I = Pre_parser.MenhirInterpreter in + let checkpoint = Pre_parser.Incremental.translation_unit_file() + and supplier = I.lexer_lexbuf_to_supplier lexer lexbuf + and succeed () = () + and fail checkpoint = + Cerrors.fatal_error_raw "syntax error" + in + I.loop_handle succeed fail supplier checkpoint + + let tokens_stream filename text : token coq_Stream = contexts_stk := [init_ctx]; - Pre_parser.translation_unit_file (lexer tokens) lexbuf; + let tokens = Queue.create () in + invoke_pre_parser filename text (lexer tokens); assert (List.length !contexts_stk = 1); let rec compute_token_stream () = let loop t v = -- cgit From f8be3f5f2937b053b9cb75ada7937a6c1b20f019 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:34:43 +0200 Subject: Install the new system for reporting syntax errors. 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. --- .gitignore | 7 + Makefile.extr | 9 +- cparser/ErrorReports.ml | 239 ++ cparser/ErrorReports.mli | 28 + cparser/GNUmakefile | 175 ++ cparser/Lexer.mll | 21 +- cparser/deLexer.ml | 120 + cparser/handcrafted.messages | 5162 ++++++++++++++++++++++++++++++++++++++ cparser/tests/generated/Makefile | 38 + 9 files changed, 5791 insertions(+), 8 deletions(-) create mode 100644 cparser/ErrorReports.ml create mode 100644 cparser/ErrorReports.mli create mode 100644 cparser/GNUmakefile create mode 100644 cparser/deLexer.ml create mode 100644 cparser/handcrafted.messages create mode 100644 cparser/tests/generated/Makefile diff --git a/.gitignore b/.gitignore index 296dac75..1dc6c42c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,14 @@ cparser/Parser.v cparser/Lexer.ml cparser/pre_parser.ml cparser/pre_parser.mli +cparser/pre_parser_messages.ml cparser/pre_parser.automaton +cparser/pre_parser.messages +cparser/handcrafted.messages.bak +cparser/handcrafted.messages.raw +cparser/deLexer +cparser/tests/generated/*.c +cparser/tests/generated/*.err backend/CMparser.automaton lib/Readconfig.ml lib/Tokenize.ml diff --git a/Makefile.extr b/Makefile.extr index 6a03f1e1..fce0d933 100644 --- a/Makefile.extr +++ b/Makefile.extr @@ -17,10 +17,15 @@ include Makefile.config -# Menhir configuration and rules. +# Menhir configuration. include Makefile.menhir +# The pre-parser's error message database is compiled as follows. + +cparser/pre_parser_messages.ml: + $(MAKE) -C cparser correct + # Directories containing plain Caml code (no preprocessing) DIRS=extraction \ @@ -87,7 +92,7 @@ LIBS_BYTE=$(patsubst %.cmxa,%.cma,$(patsubst %.cmx,%.cmo,$(LIBS))) CHECKLINK_LIBS=str.cmxa EXECUTABLES=ccomp ccomp.byte cchecklink cchecklink.byte clightgen clightgen.byte -GENERATED=$(PARSERS:.mly=.mli) $(PARSERS:.mly=.ml) $(LEXERS:.mll=.ml) +GENERATED=$(PARSERS:.mly=.mli) $(PARSERS:.mly=.ml) $(LEXERS:.mll=.ml) cparser/pre_parser_messages.ml # Beginning of part that assumes .depend.extr already exists diff --git a/cparser/ErrorReports.ml b/cparser/ErrorReports.ml new file mode 100644 index 00000000..445b8412 --- /dev/null +++ b/cparser/ErrorReports.ml @@ -0,0 +1,239 @@ +open Lexing +open Pre_parser.MenhirInterpreter +module S = MenhirLib.General (* Streams *) + +(* -------------------------------------------------------------------------- *) + +(* There are places where we may hit an internal error and we would like to fail + abruptly because "this cannot happen". Yet, it is safer when shipping to + silently cover up for our internal error. Thus, we typically use an idiom of + the form [if debug then assert false else ]. *) + +let debug = true + +(* -------------------------------------------------------------------------- *) + +(* The parser keeps track of the last two tokens in a two-place buffer. *) + +type 'a buffer = +| Zero +| One of 'a +| Two of 'a * (* most recent: *) 'a + +(* [push buffer x] pushes [x] into [buffer], causing the buffer to slide. *) + +let update buffer x : _ buffer = + match buffer, x with + | Zero, _ -> + One x + | One x1, x2 + | Two (_, x1), x2 -> + Two (x1, x2) + +(* [show f buffer] prints the contents of the buffer. The function [f] is + used to print an element. *) + +let show f buffer : string = + match buffer with + | Zero -> + (* The buffer cannot be empty. If we have read no tokens, we + cannot have detected a syntax error. *) + if debug then assert false else "" + | One invalid -> + (* It is unlikely, but possible, that we have read just one token. *) + Printf.sprintf "before '%s'" (f invalid) + | Two (valid, invalid) -> + (* In the most likely case, we have read two tokens. *) + Printf.sprintf "after '%s' and before '%s'" (f valid) (f invalid) + +(* [last buffer] returns the last element of the buffer (that is, the + invalid token). *) + +let last buffer = + match buffer with + | Zero -> + (* The buffer cannot be empty. If we have read no tokens, we + cannot have detected a syntax error. *) + assert false + | One invalid + | Two (_, invalid) -> + invalid + +(* -------------------------------------------------------------------------- *) + +(* [extract text (pos1, pos2)] extracts the sub-string of [text] delimited + by the positions [pos1] and [pos2]. *) + +let extract text (pos1, pos2) : string = + let ofs1 = pos1.pos_cnum + and ofs2 = pos2.pos_cnum in + let len = ofs2 - ofs1 in + try + String.sub text ofs1 len + with Invalid_argument _ -> + (* In principle, this should not happen, but if it does, let's make this + a non-fatal error. *) + if debug then assert false else "???" + +(* -------------------------------------------------------------------------- *) + +(* [sanitize text] eliminates any special characters from the text [text]. + They are (arbitrarily) replaced with a single dot character. *) + +let sanitize text = + String.map (fun c -> + if Char.code c < 32 || Char.code c >= 127 then '.' else c + ) text + +(* -------------------------------------------------------------------------- *) + +(* [shorten k text] limits the length of [text] to [2k+3] characters. If the + text is too long, a fragment in the middle is replaced with an ellipsis. *) + +let shorten k text = + let n = String.length text in + if n <= 2 * k + 3 then + text + else + String.sub text 0 k ^ + "..." ^ + String.sub text (n - k) k + +(* -------------------------------------------------------------------------- *) + +(* [stack checkpoint] extracts the parser's stack out of a checkpoint. *) + +let stack checkpoint = + match checkpoint with + | HandlingError env -> + stack env + | _ -> + assert false (* this cannot happen, I promise *) + +(* -------------------------------------------------------------------------- *) + +(* [state checkpoint] extracts the number of the current state out of a + parser checkpoint. *) + +let state checkpoint : int = + match Lazy.force (stack checkpoint) with + | S.Nil -> + (* Hmm... The parser is in its initial state. Its number is + usually 0. This is a BIG HACK. TEMPORARY *) + 0 + | S.Cons (Element (s, _, _, _), _) -> + number s + +(* -------------------------------------------------------------------------- *) + +(* TEMPORARY move to MenhirLib.General *) + +let rec drop n (xs : 'a S.stream) : 'a S.stream = + match n, xs with + | 0, _ + | _, lazy (S.Nil) -> + xs + | _, lazy (S.Cons (_, xs)) -> + drop (n - 1) xs + +(* -------------------------------------------------------------------------- *) + +(* [element checkpoint i] returns the [i]-th cell of the parser stack. The index + [i] is 0-based. [i] should (ideally) be within bounds; we raise [Not_found] + if it isn't. *) + +let element checkpoint i : element = + match Lazy.force (drop i (stack checkpoint)) with + | S.Nil -> + (* [i] is out of range. This could happen if the handwritten error + messages are out of sync with the grammar, or if a mistake was + made. We fail in a non-fatal way. *) + raise Not_found + | S.Cons (e, _) -> + e + +(* -------------------------------------------------------------------------- *) + +(* [range text e] converts the stack element [e] to the fragment of the source + text that corresponds to this stack element. The fragment is placed within + single quotes and shortened if it is too long. We also ensure that it does + not contain any special characters. *) + +let width = 30 + +let range text (e : element) : string = + (* Extract the start and positions of this stack element. *) + let Element (_, _, pos1, pos2) = e in + (* Get the underlying source text fragment. *) + let fragment = extract text (pos1, pos2) in + (* Sanitize it and limit its length. Enclose it in single quotes. *) + "'" ^ shorten width (sanitize fragment) ^ "'" + +(* -------------------------------------------------------------------------- *) + +(* We allow an error message to contain the special form $i, where is a 0-based + index into the stack. We replace it with the fragment of the source text that + corresponds to this stack entry. *) + +let fragment text checkpoint message = + try + let i = int_of_string (Str.matched_group 1 message) in + range text (element checkpoint i) + with + | Failure _ -> + (* In principle, this should not happen, but if it does, let's cover up + for our internal error. *) + if debug then assert false else "???" + | Not_found -> + (* In principle, this should not happen, but if it does, let's cover up + for our internal error. *) + if debug then assert false else "???" + +let fragments text checkpoint (message : string) : string = + Str.global_substitute + (Str.regexp "\\$\\([0-9]+\\)") + (fragment text checkpoint) + message + +(* -------------------------------------------------------------------------- *) + +(* [report text buffer checkpoint] constructs an error message. The C source + code must be stored in the string [text]. The start and end positions of the + last two tokens that were read must be stored in [buffer]. The parser state + (i.e., the automaton's state and stack) must be recorded in the checkpoint + [checkpoint]. *) + +(* The start and end positions of the invalid token are [lexbuf.lex_start_p] + and [lexbuf.lex_curr_p], since this is the last token that was read. But + we need not care about that here. *) + +let report text buffer checkpoint : string = + (* Extract the position where the error occurred, that is, the start + position of the invalid token. We display it as a filename, a (1-based) + line number, and a (0-based) column number. *) + let (pos, _) = last buffer in + (* Construct a readable description of where the error occurred, that is, + after which token and before which token. *) + let where = show (extract text) buffer in + (* Find out in which state the parser failed. *) + let s : int = state checkpoint in + (* Choose an error message, based on the state number [s]. + Then, customize it, based on dynamic information. *) + let message = try + Pre_parser_messages.message s |> + fragments text checkpoint + with Not_found -> + (* If the state number cannot be found -- which, in principle, + should not happen, since our list of erroneous states is + supposed to be complete! -- produce a generic message. *) + Printf.sprintf "This is an unknown syntax error (%d).\n\ + Please report this problem to the compiler vendor.\n" s + in + (* Construct the full error message. *) + Printf.sprintf "%s:%d:%d: syntax error %s.\n%s" + pos.pos_fname + pos.pos_lnum + (pos.pos_cnum - pos.pos_bol) + where + message + diff --git a/cparser/ErrorReports.mli b/cparser/ErrorReports.mli new file mode 100644 index 00000000..e4296e69 --- /dev/null +++ b/cparser/ErrorReports.mli @@ -0,0 +1,28 @@ +(* This module is in charge of reporting a syntax error after the pre_parser + has failed. *) + +open Pre_parser.MenhirInterpreter + +(* The parser keeps track of the last two tokens in a two-place buffer. *) + +type 'a buffer = +| Zero +| One of 'a +| Two of 'a * (* most recent: *) 'a + +(* [push buffer x] pushes [x] into [buffer], causing the buffer to slide. *) + +val update: 'a buffer -> 'a -> 'a buffer + +(* [report text buffer checkpoint] constructs an error message. The C source + code must be stored in the string [text]. The start and end positions of the + last two tokens that were read must be stored in [buffer]. The parser state + (i.e., the automaton's state and stack) must be recorded in the checkpoint + [checkpoint]. *) + +val report: + string -> + (Lexing.position * Lexing.position) buffer -> + _ checkpoint -> + string + diff --git a/cparser/GNUmakefile b/cparser/GNUmakefile new file mode 100644 index 00000000..6c1df250 --- /dev/null +++ b/cparser/GNUmakefile @@ -0,0 +1,175 @@ +# This is a development Makefile. +# It is meant to be used by developers who wish to modify the pre_parser. + +# A collection of erroneous input sentences (and accompanying error messages) +# for the pre_parser is stored in the file handcrafted.messages. + +# After a modification to the pre_parser, one must ensure that this collection of +# erroneous input sentences remains correct, irredundant, and complete. By this, +# we mean: +# - every input sentence in the collection leads to an error (on its last token); +# - every state where an error can occur is reached by some input sentence in the +# collection; +# - every state where an error can occur is reached by at most one input sentence +# in the collection. + +# These properties are checked by [make correct] and [make complete] below. +# [make correct] is cheap and is performed automatically when CompCert is +# compiled. [make complete] is expensive and must be called explicitly. + +# After a modification to the pre_parser, one should also reconstruct the +# auto-generated comments in handcrafted.messages. This is done by calling +# [make update]. + +# Finally, after a modification to the pre_parser, one should ensure that every +# error message remains meaningful. Indeed, an error message should not be +# specific of the example sentence that causes this error; it should reflect all +# possible sentences that cause an error in this state. One must look at the +# description of the error state (which is part of the auto-generated comments) +# and decide, based on this description, whether the error message seems +# appropriate. + +# If you wish to play with one input sentence and see how the automaton behaves, +# use [make interpret] or [make interpret_error]. + +# If you wish to translate the database of erroneous input sentences to concrete +# syntax, so as to be able to run a C compiler on these sentences, use [make +# concrete]. + +# ------------------------------------------------------------------------------ + +# Make sure we use the same Menhir setup as the main CompCert Makefiles. + +include ../Makefile.menhir + +# Be more verbose about the automaton. + +FLAGS := $(MENHIR_FLAGS) -v -la 2 + +# So, here is our basic Menhir command. + +COMMAND := $(MENHIR) $(MENHIR_MODE) pre_parser.mly $(FLAGS) + +# And this is the database of messages. + +DATABASE := handcrafted.messages + +# We use (GNU) cut when de-lexing examples sentences. + +CUT := $(shell if which gcut >/dev/null ; then echo gcut ; else echo cut ; fi) + +# ------------------------------------------------------------------------------ + +# Working with the error message database. + +.PHONY: nothing correct complete update + +nothing: + @ echo "If you wish to compile CompCert, please run \"make\" one level up." + @ echo "If you wish to work on the pre-parser, please read GNUmakefile." + +# Checking correctness and irredundancy is done via --compile-errors. +# This entry is also called from [Makefile.extr] to compile the message +# database down to OCaml code. +# This also produces a description of the automaton in pre_parser.automaton +# and a description of the conflicts (if any) in pre_parser.conflicts. +correct: + @ $(COMMAND) --compile-errors $(DATABASE) > pre_parser_messages.ml && \ + echo "OK. The set of erroneous inputs is correct and irredundant." + +# Checking completeness is done by first generating a complete list of +# erroneous sentences (in pre_parser.messages), then comparing the two +# .messages files for inclusion. +complete: +# Re-generate the list of error messages. This takes time (about 25 seconds). + @ $(COMMAND) --list-errors >pre_parser.messages + @ echo "Number of error sentences that involve spurious reductions:" + @ grep WARNING pre_parser.messages | wc -l +# Check $(DATABASE) for completeness. +# We assume pre_parser.messages is up-to-date. + @ $(COMMAND) --compare-errors pre_parser.messages --compare-errors $(DATABASE) && \ + echo "OK. The set of erroneous inputs is complete." + +update: +# Update the auto-comments in $(DATABASE). + @ mv -f $(DATABASE) $(DATABASE).bak + @ if ! $(COMMAND) --update-errors $(DATABASE).bak > $(DATABASE) ; then \ + cp $(DATABASE).bak $(DATABASE) ; \ + fi + @ echo "The auto-generated comments in $(DATABASE) have been re-generated." + +# ------------------------------------------------------------------------------ + +# Trying out an input sentence. + +# [make interpret] waits for you to interactively type an input sentence, +# in symbolic syntax (e.g. ALIGNAS LPAREN TYPEDEF_NAME INT). It runs the +# automaton on this sentence in --trace mode. + +# [make interpret_error] is analogous, but expects the sentence to cause +# an error at the last token, and displays in what state the error takes +# place. + +.PHONY: interpret interpret_error + +interpret: +# Interpret one sentence (interactive). + @ $(COMMAND) --trace --interpret + +interpret_error: +# Interpret one error sentence (interactive). + @ $(COMMAND) --interpret-error + +# ------------------------------------------------------------------------------ + +# Translating the database of erroneous input sentences to concrete syntax. + +# [make concrete] destroys and re-creates the C files in tests/generated/. +# Once this is done, run [make -C tests/generated] to submit these C files +# to CompCert, clang and gcc. + +.PHONY: concrete + +# First, we translate $(DATABASE) to a text file which contains just the +# erroneous input sentences, nothing else (no comments, no blank lines). +%.messages.raw: %.messages + @ $(COMMAND) --echo-errors $< > $@ + +# We compile deLexer.ml to native code, because running it as an ocaml script +# is way too slow. This little utility translates symbolic tokens to their +# concrete C syntax, e.g., EQ is translated to = and so on. +deLexer: deLexer.ml + @ ocamlopt -o $@ str.cmxa $< + +concrete: $(DATABASE).raw deLexer +# Destroy the C files in tests/generated. + @ rm -f tests/generated/*.c +# Read $(DATABASE).raw, line by line. +# For each sentence, create a new C file. +# A sentence takes the form ": SYMBOLS...". +# We cut the start symbol away, +# and translate the rest to concrete C syntax using the deLexer. +# We declare a type name "t", which the de-lexer uses as a type name. + @ f=0 ; \ + while read -r line ; do \ + filename=`printf "tests/generated/%03d.c" $$f` ; \ + rm -f $$filename ; \ + echo "typedef int t;" >> $$filename ; \ + echo "$$line" \ + | $(CUT) --fields="1" --delimiter=" " --complement \ + | ./deLexer \ + >> $$filename ; \ + f=$$((f+1)) ; \ + done < $< + +# ------------------------------------------------------------------------------ + +# Cleaning up. + +clean: + rm -f pre_parser.automaton + rm -f pre_parser.conflicts + rm -f pre_parser.messages + rm -f $(DATABASE).raw + rm -f deLexer + diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll index 62764a48..23d8ab8d 100644 --- a/cparser/Lexer.mll +++ b/cparser/Lexer.mll @@ -449,19 +449,24 @@ and singleline_comment = parse else initial lexbuf - (* [lexer tokens buffer] is a new lexer, which wraps [lexer], and also - records the token stream into the FIFO queue [tokens]. *) + (* [lexer tokens buffer] is a new lexer, which wraps [lexer], and also: 1- + records the token stream into the FIFO queue [tokens] and 2- records the + start and end positions of the last two tokens in the two-place buffer + [buffer]. *) - let lexer tokens : lexbuf -> Pre_parser.token = + let lexer tokens buffer : lexbuf -> Pre_parser.token = fun lexbuf -> let token = lexer lexbuf in Queue.push token tokens; + let startp = lexbuf.lex_start_p + and endp = lexbuf.lex_curr_p in + buffer := ErrorReports.update !buffer (startp, endp); token (* [invoke_pre_parser] is in charge of calling the pre_parser. It uses the incremental API, which allows us to do our own error handling. *) - let invoke_pre_parser filename text lexer = + let invoke_pre_parser filename text lexer buffer = let lexbuf = Lexing.from_string text in lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname = filename; pos_lnum = 1}; let module I = Pre_parser.MenhirInterpreter in @@ -469,14 +474,18 @@ and singleline_comment = parse and supplier = I.lexer_lexbuf_to_supplier lexer lexbuf and succeed () = () and fail checkpoint = - Cerrors.fatal_error_raw "syntax error" + Cerrors.fatal_error_raw "%s" (ErrorReports.report text !buffer checkpoint) in I.loop_handle succeed fail supplier checkpoint + (* [tokens_stream filename text] runs the pre_parser and produces a stream + of (appropriately classified) tokens. *) + let tokens_stream filename text : token coq_Stream = contexts_stk := [init_ctx]; let tokens = Queue.create () in - invoke_pre_parser filename text (lexer tokens); + let buffer = ref ErrorReports.Zero in + invoke_pre_parser filename text (lexer tokens buffer) buffer; assert (List.length !contexts_stk = 1); let rec compute_token_stream () = let loop t v = diff --git a/cparser/deLexer.ml b/cparser/deLexer.ml new file mode 100644 index 00000000..7ecfca0c --- /dev/null +++ b/cparser/deLexer.ml @@ -0,0 +1,120 @@ +(* [delex] converts a terminal symbol (represented as a symbolic string) to a + concrete string, which the lexer would accept. *) + +(* This can be used to convert an error sentence produced by Menhir to C code. *) + +(* [delex] should be maintained in sync with the lexer! *) + +let delex (symbol : string) : string = + match symbol with + | "ALIGNAS" -> "_Alignas" + | "ALIGNOF" -> "__alignof__" (* use the gcc-compatible form *) + | "UNDERSCORE_BOOL" -> "_Bool" + | "ASM" -> "__asm" + | "ATTRIBUTE" -> "__attribute" + | "BUILTIN_VA_ARG" -> "__builtin_va_arg" + | "CONST" -> "const" + | "INLINE" -> "inline" + | "PACKED" -> "__packed__" + | "RESTRICT" -> "restrict" + | "SIGNED" -> "signed" + | "VOLATILE" -> "volatile" + | "AUTO" -> "auto" + | "BREAK" -> "break" + | "CASE" -> "case" + | "CHAR" -> "char" + | "CONTINUE" -> "continue" + | "DEFAULT" -> "default" + | "DO" -> "do" + | "DOUBLE" -> "double" + | "ELSE" -> "else" + | "ENUM" -> "enum" + | "EXTERN" -> "extern" + | "FLOAT" -> "float" + | "FOR" -> "for" + | "GOTO" -> "goto" + | "IF" -> "if" + | "INT" -> "int" + | "LONG" -> "long" + | "REGISTER" -> "register" + | "RETURN" -> "return" + | "SHORT" -> "short" + | "SIZEOF" -> "sizeof" + | "STATIC" -> "static" + | "STRUCT" -> "struct" + | "SWITCH" -> "switch" + | "TYPEDEF" -> "typedef" + | "UNION" -> "union" + | "UNSIGNED" -> "unsigned" + | "VOID" -> "void" + | "WHILE" -> "while" + | "TYPEDEF_NAME" -> "t" (* this should be a type name *) + | "VAR_NAME" -> "x" (* this should be a variable name *) + | "CONSTANT" -> "42" + | "STRING_LITERAL" -> "\"\"" + | "ELLIPSIS" -> "..." + | "ADD_ASSIGN" -> "+=" + | "SUB_ASSIGN" -> "-=" + | "MUL_ASSIGN" -> "*=" + | "DIV_ASSIGN" -> "/=" + | "MOD_ASSIGN" -> "%=" + | "OR_ASSIGN" -> "|=" + | "AND_ASSIGN" -> "&=" + | "XOR_ASSIGN" -> "^=" + | "LEFT_ASSIGN" -> "<<=" + | "RIGHT_ASSIGN" -> ">>=" + | "LEFT" -> "<<" + | "RIGHT" -> ">>" + | "EQEQ" -> "==" + | "NEQ" -> "!=" + | "LEQ" -> "<=" + | "GEQ" -> ">=" + | "EQ" -> "=" + | "LT" -> "<" + | "GT" -> ">" + | "INC" -> "++" + | "DEC" -> "--" + | "PTR" -> "->" + | "PLUS" -> "+" + | "MINUS" -> "-" + | "STAR" -> "*" + | "SLASH" -> "/" + | "PERCENT" -> "%" + | "BANG" -> "!" + | "ANDAND" -> "&&" + | "BARBAR" -> "||" + | "AND" -> "&" + | "BAR" -> "|" + | "HAT" -> "^" + | "QUESTION" -> "?" + | "COLON" -> ":" + | "TILDE" -> "~" + | "LBRACE" -> "{" + | "RBRACE" -> "}" + | "LBRACK" -> "[" + | "RBRACK" -> "]" + | "LPAREN" -> "(" + | "RPAREN" -> ")" + | "SEMICOLON" -> ";" + | "COMMA" -> "," + | "DOT" -> "." + | "PRAGMA" -> "#pragma \n" + | "EOF" -> "" (* this should be ok *) + | _ -> raise Not_found (* this should not happen *) + +(* De-lexing a sentence. *) + +let delex sentence = + let symbols = Str.split (Str.regexp " ") sentence in + let symbols = List.map delex symbols in + List.iter (fun symbol -> + Printf.printf "%s " symbol + ) symbols + +(* This file is meant to be run as a script. We read one line from the standard + input channel and delex it. *) + +let () = + delex (input_line stdin); + print_newline() + diff --git a/cparser/handcrafted.messages b/cparser/handcrafted.messages new file mode 100644 index 00000000..1d78360a --- /dev/null +++ b/cparser/handcrafted.messages @@ -0,0 +1,5162 @@ +# This file contains a complete list of sentences that cause the pre_parser to +# detect an error. + +# ------------------------------------------------------------------------------ + +# WORKFLOW: + +# The workflow (when and how this file should be modified; which tools exist +# to maintain it; etc.) is documented in GNUmakefile in this directory. + +# ------------------------------------------------------------------------------ + +# FILE FORMAT: + +# Each sentence is followed with a hand-written error message, which must be +# preceded and followed by a blank line. + +# If several sentences should share a single error message, they can be grouped, +# with no whitespace between them. + +# Hand-written comments, which begin with a single hash character, like this, are +# preserved when this file is updated by Menhir. Auto-generated comments, which +# begin with two hash characters, are re-generated by Menhir. + +# An error message is basically free-form text. It cannot contain a blank line. +# Occurrences of the special form $i, where i is a number (an index into the +# parser's stack), will be replaced by the fragment of the source text that +# corresponds to this stack entry. It is the user's responsibility to ensure +# that the index i is within range, i.e., falls into the known suffix of the +# stack. Note that this index is 0-based and counts from right to left, i.e., +# $0 refers to the RIGHTMOST stack cell. + +# The replacement text for $i can be quite long (up to one line, basically) +# so one should avoid using several $i on a single line, unless one knows +# a smaller bound on their length. + +# ------------------------------------------------------------------------------ + +# CONVENTIONS ABOUT THE FORM AND STYLE OF ERROR MESSAGES: + +# If possible, start with "Ill-formed foo", where "foo" is the thing that we +# are trying to recognize, i.e., the left-hand side of our items. This is not +# always possible, as we do not always know with certainty what we are trying +# to rcognize. + +# If possible, say "Up to this point, a bar has been recognized", and show it, +# by using $i. + +# If the current state was reached via spurious reductions, print a hypothesis, +# of the form "If this bar is complete, then". + +# Show a list of the permitted continuations: "at this point, one of the +# following is expected:". The list should be complete, although unlikely +# continuations can be omitted. A continuation can be just one symbol, or +# a sequence of symbols. + +# ------------------------------------------------------------------------------ + +# NOTE ON THE CONTEXT OF AN EXPRESSION: + +# A C expression occurs in many contexts. + +# Although we could distinguish between these contexts statically, by adding a +# phantom parameter to all of the nonterminal symbols that encode expressions, +# that would be quite heavy: the number of states in the automaton would grow +# quite dramatically. + +# Instead, we prefer to dynamically distinguish between these contexts. We do +# so in a very simple way: we give --on-error-reduce directives to Menhir (in +# the Makefile) so as to replace certain error actions with reduction actions. +# Thus, when Menhir finds an error and whatever is on the stack can be reduced +# to an expression, the automaton will reduce it to an expression. By carrying +# out this extra (spurious) reduction, the automaton ends up in a state where +# sufficient static context is available to tell what should follow. Thus, +# without doing anything special beyond giving these directives, we are able +# to sidestep the issue of the context of expressions. + +# Of course, we must be careful to say (in our error messages) "IF this +# expression (or list of expressions) is complete, THEN the following +# continuations are expected". The weakness of this approach is that if the +# expression is NOT complete (in the user's mind), then we do not help the user +# understand how the expression should be completed. Our error message exhibits +# a bias towards ending expressions. + +# OTHER USES OF --on-reduce-error: + +# We apply this technique also to attribute_specifier_list and declarator. This +# means, intuitively, that when we find an error at a position where an +# attribute specifier list and/or a declarator could be complete, but could also +# be continued, we implicitly assume it is complete. Again, this must be taken +# into account in messages where an attribute_specifier_list or a declarator has +# just been recognized. + +# ABOUT STRICT VERSUS LAX INTERPRETATIONS OF --on-reduce-error: + +# There are two ways in which Menhir could implement --on-reduce-error. In the +# strict interpretation, an extra reduction takes place only if this is the +# only reduction that can take place in this state. (Thus, we do not choose +# between two interpretations of the past.) In the lax interpretation, an extra +# reduction can take place even if some other reduction is enabled. (In a +# situation where two extra reductions compete, neither takes place.) + +# Adopting the lax interpretation adds more extra reductions, causing some +# error states to disappear. For instance, this state, where we have a read +# a VAR_NAME which could be either the beginning of an expression or the +# beginning of a labeled statement: + +# general_identifier -> VAR_NAME . [ COLON ] +# primary_expression -> VAR_NAME . [ ] + +# In the strict interpretation, no extra reduction is permitted here, because +# two reductions are enabled. In the lax interpretation, because we have +# requested --on-error-reduce primary_expression, the second production is +# reduced. Hence, we implicitly assume that this name forms an expression +# (as opposed to a label). This is slightly inaccurate (we lose completeness) +# but removes an error state that is rather unpleasant. + +# Even though it may sound "bad" to arbitrarily force one reduction among +# several possible reductions, one should keep in mind that an arbitrary +# choice is already made for us by the user when he "chooses" the incorrect +# token. Indeed, depending on which incorrect token is used, we may fall +# within or outside of a lookahead set, so we may make different reduction +# choices, and give different error messages. So, we shouldn't feel too bad +# about forcing a few more arbitrary choices. This is actually more regular, +# in a sense. + +# In another instance of this phenomemon, there is a rather tricky state, +# where we have read "int f" at the toplevel, and we do not know whether this +# will be a variable definition (declarator) or a function definition +# (direct_declarator). In the lax interpretation, because we have requested +# --on-error-reduce declarator, we implicitly assume this must be the +# beginning of a declarator. Again, we lose completeness (we will not suggest +# that an opening parenthesis would have been accepted) but this makes our +# life easier, and does not sound too bad. + +# Another instance is a state where we have read "enum foo". This could be a +# complete enum_specifier, or it could be continued with an opening brace. If it +# is complete, though, we lack static context to tell what should come after it. +# Using lax --on-error-reduce enum_specifier allows us to force a reduction, +# (thus forgetting that an opening brace would have been permitted) and to move +# to another state where more contextual information is available. As noted +# above, this reduction can already take place naturally, depending on the +# lookahead token, so we are only adding more cases where it takes place. + +# The lax --on-reduce-error is used also to deal with a family of error states +# where we have recognized a complete statement which could be continued with an +# ELSE branch. These error states are difficult to explain: although we can +# definitely say that ELSE is permitted, we have difficulty telling what else is +# permitted, by lack of static context. We could recover this static information +# by introducing a phantom parameter on statements, but that would be heavy. We +# just cut a corner and use --on-reduce-error to view this as a complete +# statement. Thus, we abandon the possibility that the statement could be +# continued with ELSE: our error message will not mention it. Again, this makes +# our life easier, and does not sound too bad. + +# We also apply --on-error-reduce to specifier_qualifier_list and +# option(abstract_declarator(type_name)). This allows us to recognize +# a valid type name, even when this type name could be continued. This +# allows us to go back to a state where we see the opening parenthesis +# before the type name (there is always one), which allows us to +# explain why we request a closing parenthesis. This is a bit costly, +# as there are quite a few similar error states to deal with here. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN TYPEDEF_NAME INT +## +## Ends in an error in state: 177. +## +## attribute_specifier -> ALIGNAS LPAREN type_name . RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ALIGNAS LPAREN type_name +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 185, spurious reduction of production specifier_qualifier_list(type_name) -> option(type_qualifier_list) TYPEDEF_NAME option(type_qualifier_list) +## In state 148, spurious reduction of production option(abstract_declarator(type_name)) -> +## In state 324, spurious reduction of production type_name -> specifier_qualifier_list(type_name) option(abstract_declarator(type_name)) +## + +# Maybe the type name was not complete, but we have reduced anyway +# and assume it is complete. Thus, we expect a closing parenthesis. +# This example comes in several variants, because there are several +# places in the grammar where LPAREN type_name RPAREN appears. + +# gcc, clang: like us, expect a closing parenthesis. + +Ill-formed _Alignas qualifier. +Up to this point, a type name has been recognized: + $2 $1 $0 +If this type name is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ ALIGNOF LPAREN VOID XOR_ASSIGN +## +## Ends in an error in state: 122. +## +## postfix_expression -> LPAREN type_name . RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## unary_expression -> ALIGNOF LPAREN type_name . RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## ALIGNOF LPAREN type_name +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 214, spurious reduction of production specifier_qualifier_list(type_name) -> option(type_qualifier_list) type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) +## In state 148, spurious reduction of production option(abstract_declarator(type_name)) -> +## In state 324, spurious reduction of production type_name -> specifier_qualifier_list(type_name) option(abstract_declarator(type_name)) +## +translation_unit_file: INT VAR_NAME EQ SIZEOF LPAREN VOID XOR_ASSIGN +## +## Ends in an error in state: 340. +## +## postfix_expression -> LPAREN type_name . RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## unary_expression -> SIZEOF LPAREN type_name . RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## SIZEOF LPAREN type_name +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 214, spurious reduction of production specifier_qualifier_list(type_name) -> option(type_qualifier_list) type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) +## In state 148, spurious reduction of production option(abstract_declarator(type_name)) -> +## In state 324, spurious reduction of production type_name -> specifier_qualifier_list(type_name) option(abstract_declarator(type_name)) +## + +Ill-formed use of $2. +Up to this point, a type name has been recognized: + $0 +If this type name is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ BUILTIN_VA_ARG LPAREN VAR_NAME COMMA VOID XOR_ASSIGN +## +## Ends in an error in state: 331. +## +## postfix_expression -> BUILTIN_VA_ARG LPAREN assignment_expression COMMA type_name . RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## BUILTIN_VA_ARG LPAREN assignment_expression COMMA type_name +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 214, spurious reduction of production specifier_qualifier_list(type_name) -> option(type_qualifier_list) type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) +## In state 148, spurious reduction of production option(abstract_declarator(type_name)) -> +## In state 324, spurious reduction of production type_name -> specifier_qualifier_list(type_name) option(abstract_declarator(type_name)) +## + +Ill-formed use of __builtin_va_arg. +Up to this point, a type name has been recognized: + $4 $3 $2 $1 $0 +If this type name is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ INC LPAREN VOID XOR_ASSIGN +## +## Ends in an error in state: 334. +## +## postfix_expression -> LPAREN type_name . RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN type_name +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 214, spurious reduction of production specifier_qualifier_list(type_name) -> option(type_qualifier_list) type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) +## In state 148, spurious reduction of production option(abstract_declarator(type_name)) -> +## In state 324, spurious reduction of production type_name -> specifier_qualifier_list(type_name) option(abstract_declarator(type_name)) +## + +# gcc simply says it expects a closing parenthesis, +# but clang says it expects a closing parenthesis and an opening brace. + +Ill-formed compound literal. +Up to this point, a type name has been recognized: + $1 $0 +If this type name is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LPAREN VOID XOR_ASSIGN +## +## Ends in an error in state: 337. +## +## cast_expression -> LPAREN type_name . RPAREN cast_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## postfix_expression -> LPAREN type_name . RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN type_name +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 214, spurious reduction of production specifier_qualifier_list(type_name) -> option(type_qualifier_list) type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) +## In state 148, spurious reduction of production option(abstract_declarator(type_name)) -> +## In state 324, spurious reduction of production type_name -> specifier_qualifier_list(type_name) option(abstract_declarator(type_name)) +## + +# gcc and clang say they expect a closing parenthesis. + +Up to this point, a type name has been recognized: + $1 $0 +If this type name is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 318. +## +## argument_expression_list -> argument_expression_list . COMMA assignment_expression [ RPAREN COMMA ] +## attribute_specifier -> ALIGNAS LPAREN argument_expression_list . RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ALIGNAS LPAREN argument_expression_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 109, spurious reduction of production argument_expression_list -> assignment_expression +## + +# We are trying to recognize an alignas specifier. +# We have already recognized at least one argument_expression. +# We expect either "COMMA assignment_expression" or RPAREN. +# But, in CompCert, only one expression is allowed as part of ALIGNAS (see Elab.ml). +# So we say we expect RPAREN. + +# And we say we have recognized "an expression", instead of "a list of expressions". +# Not sure whether this is a good idea. + +# gcc, clang: like us, expect a closing parenthesis. + +Ill-formed _Alignas qualifier. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN INT LBRACK RPAREN +## +## Ends in an error in state: 152. +## +## direct_abstract_declarator -> option(direct_abstract_declarator) LBRACK option(type_qualifier_list) . optional(assignment_expression,RBRACK) [ RPAREN LPAREN LBRACK COMMA ] +## type_qualifier_list -> option(type_qualifier_list) . type_qualifier [ VOLATILE VAR_NAME TILDE STRING_LITERAL STAR SIZEOF RESTRICT RBRACK PLUS PACKED MINUS LPAREN INC DEC CONSTANT CONST BUILTIN_VA_ARG BANG ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## option(direct_abstract_declarator) LBRACK option(type_qualifier_list) +## +translation_unit_file: INT VAR_NAME LBRACK RPAREN +## +## Ends in an error in state: 277. +## +## direct_declarator -> direct_declarator LBRACK option(type_qualifier_list) . optional(assignment_expression,RBRACK) [ SEMICOLON RPAREN PACKED LPAREN LBRACK LBRACE EQ COMMA COLON ATTRIBUTE ALIGNAS ] +## type_qualifier_list -> option(type_qualifier_list) . type_qualifier [ VOLATILE VAR_NAME TILDE STRING_LITERAL STAR SIZEOF RESTRICT RBRACK PLUS PACKED MINUS LPAREN INC DEC CONSTANT CONST BUILTIN_VA_ARG BANG ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## direct_declarator LBRACK option(type_qualifier_list) +## + +# We are trying to recognize an array declarator. +# We have seen the opening bracket and (maybe) some type qualifiers. +# We are expecting more type qualifiers, or an expression, or a closing bracket. + +# gcc, clang: both say they expect an expression (and nothing else). +# Yet, they do accept a closing bracket. + +# If in the first sentence we replace the invalid token with a type qualifier, such as CONST, +# gcc and clang both say: +# error: type qualifier used in array declarator outside of function prototype +# On the other hand, in the second sentence, they accept a qualifier. + +# We choose not to mention the possibility of a type qualifier (which may be +# illegal here anyway). + +Ill-formed array declarator. +At this point, one of the following is expected: + an expression, followed with a closing bracket ']'; or + a closing bracket ']'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN INT LPAREN RPAREN LPAREN INT COMMA ELLIPSIS XOR_ASSIGN +## +## Ends in an error in state: 271. +## +## direct_abstract_declarator -> direct_abstract_declarator LPAREN in_context(option(parameter_type_list)) . RPAREN [ RPAREN LPAREN LBRACK COMMA ] +## +## The known suffix of the stack is as follows: +## direct_abstract_declarator LPAREN in_context(option(parameter_type_list)) +## +translation_unit_file: ALIGNAS LPAREN INT LPAREN INT COMMA ELLIPSIS XOR_ASSIGN +## +## Ends in an error in state: 273. +## +## direct_abstract_declarator -> LPAREN in_context(option(parameter_type_list)) . RPAREN [ RPAREN LPAREN LBRACK COMMA ] +## +## The known suffix of the stack is as follows: +## LPAREN in_context(option(parameter_type_list)) +## +translation_unit_file: INT VAR_NAME LPAREN INT COMMA ELLIPSIS XOR_ASSIGN +## +## Ends in an error in state: 298. +## +## direct_declarator -> direct_declarator LPAREN open_context option(parameter_type_list) save_contexts_stk close_context . RPAREN [ SEMICOLON RPAREN PACKED LPAREN LBRACK LBRACE EQ COMMA COLON ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## direct_declarator LPAREN open_context option(parameter_type_list) save_contexts_stk close_context +## + +# Unlikely error, since only the ELLIPSIS allows us to tell that +# the parameter list is finished. + +At this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN INT LPAREN LPAREN RPAREN COMMA +## +## Ends in an error in state: 285. +## +## direct_abstract_declarator -> LPAREN abstract_declarator(type_name) . RPAREN [ RPAREN LPAREN LBRACK COMMA ] +## +## The known suffix of the stack is as follows: +## LPAREN abstract_declarator(type_name) +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 282, spurious reduction of production abstract_declarator(type_name) -> direct_abstract_declarator +## +# +# The first LPAREN in this example must be the beginning of an abstract_declarator. +# It leads us into a state where we do not yet know the meaning of the opening parenthesis: +# direct_abstract_declarator -> LPAREN . abstract_declarator RPAREN [ RPAREN LPAREN LBRACK ] +# direct_abstract_declarator -> LPAREN . in_context(option(parameter_type_list)) RPAREN [ RPAREN LPAREN LBRACK ] +# i.e. (a) this could be the opening parenthesis in a pair of parentheses, +# or (d) this could be the opening parenthesis in a function type. +# The second LPAREN takes us again into the same state. +# The RPAREN allows us to recognize that we have a function type of no parameters (d). +# Hence, LPAREN RPAREN forms a direct_abstract_declarator. +# At this point, the status of the first LPAREN is still undetermined (regular paren, +# or beginning of a function type?) but that is not a problem for us. +# +# This case is simplified by giving a phantom context parameter to abstract_declarator. +# Here, we know we are in the context of a type_name or direct_abstract_declarator, +# so RPAREN is allowed next. +# If we were in the context of a parameter_declaration, COMMA would be allowed next. +# + +# gcc and clang simply request a closing parenthesis. + +Up to this point, an abstract declarator has been recognized: + $1 $0 +At this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN INT LPAREN XOR_ASSIGN +## +## Ends in an error in state: 149. +## +## direct_abstract_declarator -> LPAREN . abstract_declarator(type_name) RPAREN [ RPAREN LPAREN LBRACK ] +## direct_abstract_declarator -> LPAREN . in_context(option(parameter_type_list)) RPAREN [ RPAREN LPAREN LBRACK ] +## +## The known suffix of the stack is as follows: +## LPAREN +## + +# gcc and clang both say they want a closing parenthesis. +# This seems a bit extreme. + +An opening parenthesis '(' has been recognized. +At this point, one of the following is expected: + an abstract declarator, + if this parenthesis is a delimiter; or + a list of parameter declarations, + if this parenthesis is the beginning of a function declarator. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT LPAREN XOR_ASSIGN +## +## Ends in an error in state: 261. +## +## direct_abstract_declarator -> LPAREN . abstract_declarator(type_name) RPAREN [ RPAREN LPAREN LBRACK COMMA ] +## direct_abstract_declarator -> LPAREN . in_context(option(parameter_type_list)) RPAREN [ RPAREN LPAREN LBRACK COMMA ] +## direct_declarator -> LPAREN . declarator RPAREN [ RPAREN PACKED LPAREN LBRACK COMMA ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## LPAREN +## + +# Analogous to the above, but has a third item. + +An opening parenthesis '(' has been recognized. +At this point, one of the following is expected: + an abstract declarator or a declarator, + if this parenthesis is a delimiter; or + a list of parameter declarations, + if this parenthesis is the beginning of a function declarator. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN VOLATILE ADD_ASSIGN +## +## Ends in an error in state: 179. +## +## specifier_qualifier_list(type_name) -> option(type_qualifier_list) . TYPEDEF_NAME option(type_qualifier_list) [ STAR RPAREN LPAREN LBRACK ] +## specifier_qualifier_list(type_name) -> option(type_qualifier_list) . type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) [ STAR RPAREN LPAREN LBRACK ] +## type_qualifier_list -> option(type_qualifier_list) . type_qualifier [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT SIGNED SHORT RESTRICT PACKED LONG INT FLOAT ENUM DOUBLE CONST CHAR ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## option(type_qualifier_list) +## + +# We are trying to recognize a specifier-qualifier-list, and have not yet seen +# a type specifier, which is why we know the list is not finished. + +# clang says it expects a type. +# gcc says the missing type defaults to int, and expects a closing parenthesis. + +Ill-formed type name. +At this point, one of the following is expected: + a type qualifier; or + a type specifier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS LPAREN XOR_ASSIGN +## +## Ends in an error in state: 176. +## +## attribute_specifier -> ALIGNAS LPAREN . argument_expression_list RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## attribute_specifier -> ALIGNAS LPAREN . type_name RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ALIGNAS LPAREN +## + +# This one seems easy. We have recognized ALIGNAS LPAREN, and nothing that makes sense beyond that. + +# clang and gcc say they expect an expression. + +Ill-formed _Alignas qualifier. +At this point, one of the following is expected: + an expression; or + a type name. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ALIGNAS XOR_ASSIGN +## +## Ends in an error in state: 175. +## +## attribute_specifier -> ALIGNAS . LPAREN argument_expression_list RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## attribute_specifier -> ALIGNAS . LPAREN type_name RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ALIGNAS +## + +# Fingers in the nose. + +Ill-formed _Alignas qualifier. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN COMMA XOR_ASSIGN +## +## Ends in an error in state: 172. +## +## gcc_attribute_list -> gcc_attribute_list COMMA . gcc_attribute [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## gcc_attribute_list COMMA +## + +# We are expecting a gcc_attribute. This symbol is nullable, so +# RPAREN and COMMA are permitted too, but we can ignore this +# possibility in the error message (why would someone use an +# empty attribute?). + +# clang and gcc say they expect a closing parenthesis. + +Ill-formed attribute specifier. +At this point, a gcc attribute is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN RPAREN XOR_ASSIGN +## +## Ends in an error in state: 170. +## +## attribute_specifier -> ATTRIBUTE LPAREN LPAREN gcc_attribute_list RPAREN . RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ATTRIBUTE LPAREN LPAREN gcc_attribute_list RPAREN +## + +Ill-formed attribute specifier. +At this point, a second closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN VAR_NAME LPAREN RPAREN XOR_ASSIGN +## +## Ends in an error in state: 169. +## +## attribute_specifier -> ATTRIBUTE LPAREN LPAREN gcc_attribute_list . RPAREN RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## gcc_attribute_list -> gcc_attribute_list . COMMA gcc_attribute [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## ATTRIBUTE LPAREN LPAREN gcc_attribute_list +## + +# We have a seen a (non-empty) attribute list, so we expect either +# a COMMA or a closing LPAREN LPAREN. + +# gcc/clang say they expect a closing parenthesis. + +Ill-formed attribute specifier. +At this point, one of the following is expected: + a comma ',', followed with a gcc attribute; or + two closing parentheses '))'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN VAR_NAME LPAREN TYPEDEF_NAME COMMA VAR_NAME SEMICOLON +## +## Ends in an error in state: 165. +## +## argument_expression_list -> argument_expression_list . COMMA assignment_expression [ RPAREN COMMA ] +## gcc_attribute -> gcc_attribute_word LPAREN TYPEDEF_NAME COMMA argument_expression_list . RPAREN [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## gcc_attribute_word LPAREN TYPEDEF_NAME COMMA argument_expression_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 109, spurious reduction of production argument_expression_list -> assignment_expression +## + +# We know for sure that we are parsing a gcc attribute. +# A (non-empty) list of expressions has been read. + +# gcc/clang say they want a closing parenthesis. + +Ill-formed gcc attribute. +Up to this point, a list of expressions has been recognized: + $0 +If this list is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN VAR_NAME LPAREN TYPEDEF_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 164. +## +## gcc_attribute -> gcc_attribute_word LPAREN TYPEDEF_NAME COMMA . argument_expression_list RPAREN [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## gcc_attribute_word LPAREN TYPEDEF_NAME COMMA +## + +# gcc/clang agree. + +Ill-formed gcc attribute. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN VAR_NAME LPAREN TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 163. +## +## gcc_attribute -> gcc_attribute_word LPAREN TYPEDEF_NAME . COMMA argument_expression_list RPAREN [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## gcc_attribute_word LPAREN TYPEDEF_NAME +## + +# gcc and clang complain about the TYPEDEF_NAME, not sure why. + +Ill-formed gcc attribute. +At this point, a comma ',' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN VAR_NAME LPAREN XOR_ASSIGN +## +## Ends in an error in state: 162. +## +## gcc_attribute -> gcc_attribute_word LPAREN . option(argument_expression_list) RPAREN [ RPAREN COMMA ] +## gcc_attribute -> gcc_attribute_word LPAREN . TYPEDEF_NAME COMMA argument_expression_list RPAREN [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## gcc_attribute_word LPAREN +## + +# gcc and clang just say they expect an expression. +# There is kind of hack in the pre_parser, here. +# Without going into the details, we should just say we expect a list of attribute arguments. + +Ill-formed gcc attribute. +At this point, a list of expressions is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 161. +## +## gcc_attribute -> gcc_attribute_word . [ RPAREN COMMA ] +## gcc_attribute -> gcc_attribute_word . LPAREN option(argument_expression_list) RPAREN [ RPAREN COMMA ] +## gcc_attribute -> gcc_attribute_word . LPAREN TYPEDEF_NAME COMMA argument_expression_list RPAREN [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## gcc_attribute_word +## + +# gcc and clang say they expect a closing parenthesis (as usual). + +Ill-formed gcc attribute specifier. +Up to this point, an attribute has been recognized: + $0 +At this point, one of the following is expected: + an opening parenthesis '(', + followed with a list of parameters for this attribute; or + a comma ',', + followed with another attribute; or + a closing parenthesis ')'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN LPAREN XOR_ASSIGN +## +## Ends in an error in state: 157. +## +## attribute_specifier -> ATTRIBUTE LPAREN LPAREN . gcc_attribute_list RPAREN RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ATTRIBUTE LPAREN LPAREN +## + +# A non-empty attribute list is expected. +# Hence, an attribute is expected. +# (The gcc documentation says a list of attributes can be empty, but +# since an attribute can be empty too, this creates a conflict.) + +# clang and gcc want a closing parenthesis, as usual (sigh)... + +Ill-formed gcc attribute specifier. +At this point, a gcc attribute is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 156. +## +## attribute_specifier -> ATTRIBUTE LPAREN . LPAREN gcc_attribute_list RPAREN RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ATTRIBUTE LPAREN +## + +Ill-formed gcc attribute specifier. +At this point, a second opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ATTRIBUTE XOR_ASSIGN +## +## Ends in an error in state: 155. +## +## attribute_specifier -> ATTRIBUTE . LPAREN LPAREN gcc_attribute_list RPAREN RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ATTRIBUTE +## + +Ill-formed gcc attribute specifier. +At this point, two opening parentheses '((' are expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ENUM LBRACE VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 200. +## +## enumerator_list -> enumerator_list COMMA . declare_varname(enumerator) [ RBRACE COMMA ] +## option(COMMA) -> COMMA . [ RBRACE ] +## +## The known suffix of the stack is as follows: +## enumerator_list COMMA +## + +# We omit the possibility of a closing brace. + +# gcc and clang say they want an identifier. +# Indeed, an enumerator must begin with an identifier. + +Ill-formed enumeration specifier. +At this point, an enumerator is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ENUM LBRACE VAR_NAME EQ CONSTANT SEMICOLON +## +## Ends in an error in state: 199. +## +## enum_specifier -> ENUM attribute_specifier_list option(other_identifier) LBRACE enumerator_list . option(COMMA) RBRACE [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## enumerator_list -> enumerator_list . COMMA declare_varname(enumerator) [ RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## ENUM attribute_specifier_list option(other_identifier) LBRACE enumerator_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 31, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 204, spurious reduction of production enumerator -> enumeration_constant EQ conditional_expression +## In state 201, spurious reduction of production declare_varname(enumerator) -> enumerator +## In state 208, spurious reduction of production enumerator_list -> declare_varname(enumerator) +## +# +# At first sight, it seems that the last enumerator that we have recognized +# could be of the form either "enumeration_constant" or +# "enumeration_constant EQ constant_expression". +# +# However, a moment's thought reveals that it cannot be of the first form, +# otherwise the syntax error would have been detected in this state: +# enumerator -> enumeration_constant . [ RBRACE COMMA ] +# enumerator -> enumeration_constant . EQ constant_expression [ RBRACE COMMA ] +# To see this, try the sentence ENUM LBRACE VAR_NAME XOR_ASSIGN. +# +# So, the last enumerator must be of the second form, which means it would be safe +# for us to say "an expression has just been recognized". +# +# On the other hand, we cannot show the expression that has just been recognized; +# we can only show the enumerator list $0. +# +# We omit the fact that a comma is allowed just before the closing brace. + +Ill-formed enumeration specifier. +Up to this point, a list of enumerators has been recognized: + $0 +If this list is complete, +then at this point, a closing brace '}' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ENUM LBRACE VAR_NAME EQ XOR_ASSIGN +## +## Ends in an error in state: 203. +## +## enumerator -> enumeration_constant EQ . conditional_expression [ RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## enumeration_constant EQ +## + +Ill-formed enumeration specifier. +At this point, a constant expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ENUM LBRACE VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 202. +## +## enumerator -> enumeration_constant . [ RBRACE COMMA ] +## enumerator -> enumeration_constant . EQ conditional_expression [ RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## enumeration_constant +## + +# Here, both clang and gcc give an incomplete diagnostic message. + +Ill-formed enumeration specifier. +At this point, one of the following is expected: + an equals sign '=', followed with a constant expression; or + a comma ',', followed with an enumerator; or + a closing brace '}'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ENUM LBRACE XOR_ASSIGN +## +## Ends in an error in state: 197. +## +## enum_specifier -> ENUM attribute_specifier_list option(other_identifier) LBRACE . enumerator_list option(COMMA) RBRACE [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ENUM attribute_specifier_list option(other_identifier) LBRACE +## + +# gcc says it expects an identifier. +# clang says it expects a closing brace (which seems incorrect). + +Ill-formed enumeration specifier. +At this point, an enumerator is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: ENUM XOR_ASSIGN +## +## Ends in an error in state: 195. +## +## attribute_specifier_list -> attribute_specifier_list . attribute_specifier [ VAR_NAME TYPEDEF_NAME PACKED LBRACE ATTRIBUTE ALIGNAS ] +## enum_specifier -> ENUM attribute_specifier_list . option(other_identifier) LBRACE enumerator_list option(COMMA) RBRACE [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## enum_specifier -> ENUM attribute_specifier_list . general_identifier [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ENUM attribute_specifier_list +## + +# Here, both clang and gcc give an incomplete diagnostic message. + +Ill-formed enumeration specifier. +At this point, one of the following is expected: + an attribute specifier; or + an identifier; or + an opening brace '{'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ ALIGNOF LPAREN XOR_ASSIGN +## +## Ends in an error in state: 29. +## +## postfix_expression -> LPAREN . type_name RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## primary_expression -> LPAREN . expression RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## unary_expression -> ALIGNOF LPAREN . type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## ALIGNOF LPAREN +## +translation_unit_file: INT VAR_NAME EQ SIZEOF LPAREN XOR_ASSIGN +## +## Ends in an error in state: 18. +## +## postfix_expression -> LPAREN . type_name RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## primary_expression -> LPAREN . expression RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## unary_expression -> SIZEOF LPAREN . type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## SIZEOF LPAREN +## + +# Tricky because we could be looking at the beginning of a compound +# literal, in which case we expect a type name! But that would be a +# use of SIZEOF or ALIGNOF without parentheses, which is very unlikely. +# So, we omit this possibility. + +# gcc/clang do the same. + +Ill-formed use of $1. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ ALIGNOF XOR_ASSIGN +## +## Ends in an error in state: 28. +## +## unary_expression -> ALIGNOF . unary_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## unary_expression -> ALIGNOF . LPAREN type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## ALIGNOF +## +translation_unit_file: INT VAR_NAME EQ SIZEOF XOR_ASSIGN +## +## Ends in an error in state: 15. +## +## unary_expression -> SIZEOF . unary_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## unary_expression -> SIZEOF . LPAREN type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## SIZEOF +## + +# Let's not reveal that _Alignof and sizeof can be used without parentheses. + +# gcc and clang say they expect an expression, which seems both surprising +# (they don't request a parenthesis) and incomplete (they don't allow a type name). + +Ill-formed use of $0. +At this point, an opening parenthesis '(' is expected, +followed with an expression or a type name. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ BUILTIN_VA_ARG LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 329. +## +## postfix_expression -> BUILTIN_VA_ARG LPAREN assignment_expression . COMMA type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## BUILTIN_VA_ARG LPAREN assignment_expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## + +Ill-formed use of $2. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a comma ',' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ BUILTIN_VA_ARG LPAREN XOR_ASSIGN +## +## Ends in an error in state: 25. +## +## postfix_expression -> BUILTIN_VA_ARG LPAREN . assignment_expression COMMA type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## BUILTIN_VA_ARG LPAREN +## + +Ill-formed use of $1. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ BUILTIN_VA_ARG XOR_ASSIGN +## +## Ends in an error in state: 24. +## +## postfix_expression -> BUILTIN_VA_ARG . LPAREN assignment_expression COMMA type_name RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## BUILTIN_VA_ARG +## + +Ill-formed use of $0. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ DEC XOR_ASSIGN +## +## Ends in an error in state: 22. +## +## unary_expression -> DEC . unary_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## DEC +## +translation_unit_file: INT VAR_NAME EQ INC XOR_ASSIGN +## +## Ends in an error in state: 20. +## +## unary_expression -> INC . unary_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## INC +## + +Ill-formed expression. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ INC LPAREN INT RPAREN XOR_ASSIGN +## +## Ends in an error in state: 335. +## +## postfix_expression -> LPAREN type_name RPAREN . LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN type_name RPAREN +## + +# Here, we seem to be certain that this must be the beginning of a +# compound literal, so an opening brace is expected. +# However, it is quite likely that the user does not even know about +# compound literals, so the error took place earlier. +# Maybe the user intended to write a cast expression, and he forgot +# to open one more parenthesis before the one we see here. +# Or maybe the name that we classified as a type was intended to be a variable. + +# gcc says an expression is expected, which seems incorrect. +# clang says "expected '{' in compound literal". + +Ill-formed expression. +Up to this point, a type name in parentheses has been recognized: + $2 $1 $0 +If this is the beginning of a compound literal, + then at this point, an opening brace '{' is expected. +If this is intended to be the beginning of a cast expression, + then perhaps an opening parenthesis '(' was forgotten earlier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ INC LPAREN XOR_ASSIGN +## +## Ends in an error in state: 21. +## +## postfix_expression -> LPAREN . type_name RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## primary_expression -> LPAREN . expression RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN +## + +# gcc and clang expect an expression. +# We could choose to omit the first possibility, too. + +Ill-formed expression. +At this point, one of the following is expected: + a type name (if this is the beginning of a compound literal); or + an expression. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 326. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## primary_expression -> LPAREN expression . RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +# Since we are saying "if this expression is complete", +# there seems to be no need to say that this expression +# can be continued with a comma and another expression. +# So, let's just say a closing parenthesis is expected. + +Up to this point, a parenthesis '(' and an expression have been recognized: + $1 $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LPAREN INT RPAREN LBRACE VAR_NAME SEMICOLON +## +## Ends in an error in state: 145. +## +## initializer_list -> initializer_list . COMMA option(designation) c_initializer [ RBRACE COMMA ] +## postfix_expression -> LPAREN type_name RPAREN LBRACE initializer_list . option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN type_name RPAREN LBRACE initializer_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 138, spurious reduction of production c_initializer -> assignment_expression +## In state 144, spurious reduction of production initializer_list -> option(designation) c_initializer +## + +# Let's ignore the fact that a comma can precede a closing brace. + +Ill-formed compound literal. +Up to this point, a list of initializers has been recognized: + $0 +If this list is complete, +then at this point, a closing brace '}' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LPAREN INT RPAREN LBRACE XOR_ASSIGN +## +## Ends in an error in state: 124. +## +## postfix_expression -> LPAREN type_name RPAREN LBRACE . initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN type_name RPAREN LBRACE +## + +# gcc and clang say an expression is expected, which is incomplete. + +Ill-formed compound literal. +At this point, an initializer is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LPAREN INT RPAREN XOR_ASSIGN +## +## Ends in an error in state: 338. +## +## cast_expression -> LPAREN type_name RPAREN . cast_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## postfix_expression -> LPAREN type_name RPAREN . LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN type_name RPAREN +## + +# clang and gcc expect an expression. + +Ill-formed expression. +Up to this point, a type name in parentheses has been recognized: + $2 $1 $0 +At this point, one of the following is expected: + an expression, if this is a type cast; or + an opening brace '{', if this is a compound literal. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LPAREN XOR_ASSIGN +## +## Ends in an error in state: 19. +## +## cast_expression -> LPAREN . type_name RPAREN cast_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## postfix_expression -> LPAREN . type_name RPAREN LBRACE initializer_list option(COMMA) RBRACE [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## primary_expression -> LPAREN . expression RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## LPAREN +## + +# clang and gcc expect an expression. + +Ill-formed expression. +An opening parenthesis '(' has just been recognized. +At this point, one of the following is expected: + a type name, if this is a type cast or a compound literal; or + an expression, if this is a parenthesized expression. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ TILDE XOR_ASSIGN +## +## Ends in an error in state: 30. +## +## unary_expression -> unary_operator . cast_expression [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LEQ LEFT_ASSIGN LEFT HAT GT GEQ EQEQ EQ DIV_ASSIGN COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## unary_operator +## + +# clang and gcc expect an expression. + +Ill-formed use of the unary operator $0. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME AND XOR_ASSIGN +## +## Ends in an error in state: 92. +## +## and_expression -> and_expression AND . equality_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION HAT COMMA COLON BARBAR BAR ANDAND AND ] +## +## The known suffix of the stack is as follows: +## and_expression AND +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME ANDAND XOR_ASSIGN +## +## Ends in an error in state: 81. +## +## logical_and_expression -> logical_and_expression ANDAND . inclusive_or_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION COMMA COLON BARBAR ANDAND ] +## +## The known suffix of the stack is as follows: +## logical_and_expression ANDAND +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME BAR XOR_ASSIGN +## +## Ends in an error in state: 83. +## +## inclusive_or_expression -> inclusive_or_expression BAR . exclusive_or_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION COMMA COLON BARBAR BAR ANDAND ] +## +## The known suffix of the stack is as follows: +## inclusive_or_expression BAR +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME BARBAR XOR_ASSIGN +## +## Ends in an error in state: 104. +## +## logical_or_expression -> logical_or_expression BARBAR . logical_and_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION COMMA COLON BARBAR ] +## +## The known suffix of the stack is as follows: +## logical_or_expression BARBAR +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME HAT XOR_ASSIGN +## +## Ends in an error in state: 85. +## +## exclusive_or_expression -> exclusive_or_expression HAT . and_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION HAT COMMA COLON BARBAR BAR ANDAND ] +## +## The known suffix of the stack is as follows: +## exclusive_or_expression HAT +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME LT XOR_ASSIGN +## +## Ends in an error in state: 75. +## +## relational_expression -> relational_expression relational_operator . shift_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION NEQ LT LEQ HAT GT GEQ EQEQ COMMA COLON BARBAR BAR ANDAND AND ] +## +## The known suffix of the stack is as follows: +## relational_expression relational_operator +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME NEQ XOR_ASSIGN +## +## Ends in an error in state: 89. +## +## equality_expression -> equality_expression equality_operator . relational_expression [ SEMICOLON RPAREN RBRACK RBRACE QUESTION NEQ HAT EQEQ COMMA COLON BARBAR BAR ANDAND AND ] +## +## The known suffix of the stack is as follows: +## equality_expression equality_operator +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME PLUS XOR_ASSIGN +## +## Ends in an error in state: 68. +## +## additive_expression -> additive_expression additive_operator . multiplicative_expression [ SEMICOLON RPAREN RIGHT RBRACK RBRACE QUESTION PLUS NEQ MINUS LT LEQ LEFT HAT GT GEQ EQEQ COMMA COLON BARBAR BAR ANDAND AND ] +## +## The known suffix of the stack is as follows: +## additive_expression additive_operator +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME RIGHT XOR_ASSIGN +## +## Ends in an error in state: 57. +## +## shift_expression -> shift_expression shift_operator . additive_expression [ SEMICOLON RPAREN RIGHT RBRACK RBRACE QUESTION NEQ LT LEQ LEFT HAT GT GEQ EQEQ COMMA COLON BARBAR BAR ANDAND AND ] +## +## The known suffix of the stack is as follows: +## shift_expression shift_operator +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME STAR XOR_ASSIGN +## +## Ends in an error in state: 62. +## +## multiplicative_expression -> multiplicative_expression multiplicative_operator . cast_expression [ STAR SLASH SEMICOLON RPAREN RIGHT RBRACK RBRACE QUESTION PLUS PERCENT NEQ MINUS LT LEQ LEFT HAT GT GEQ EQEQ COMMA COLON BARBAR BAR ANDAND AND ] +## +## The known suffix of the stack is as follows: +## multiplicative_expression multiplicative_operator +## + +# clang and gcc expect an expression. + +Ill-formed use of the binary operator $0. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME XOR_ASSIGN XOR_ASSIGN +## +## Ends in an error in state: 53. +## +## assignment_expression -> unary_expression assignment_operator . assignment_expression [ SEMICOLON RPAREN RBRACK RBRACE COMMA COLON ] +## +## The known suffix of the stack is as follows: +## unary_expression assignment_operator +## + +# clang and gcc expect an expression. + +Ill-formed use of the assignment operator $0. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME LPAREN VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 111. +## +## argument_expression_list -> argument_expression_list COMMA . assignment_expression [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## argument_expression_list COMMA +## + +# Here, we could say more about the context if we parameterized +# argument_expression_list with a context. For the moment, let +# us just say that an expression is expected at this point. + +# clang and gcc expect an expression. + +Ill-formed list of expressions. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME DOT XOR_ASSIGN +## +## Ends in an error in state: 117. +## +## postfix_expression -> postfix_expression DOT . general_identifier [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## postfix_expression DOT +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME PTR XOR_ASSIGN +## +## Ends in an error in state: 36. +## +## postfix_expression -> postfix_expression PTR . general_identifier [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## postfix_expression PTR +## + +# clang and gcc expect an identifier. + +Ill-formed use of the dereferencing operator $0. +At this point, the name of a struct or union member is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME LBRACK VAR_NAME SEMICOLON +## +## Ends in an error in state: 114. +## +## expression -> expression . COMMA assignment_expression [ RBRACK COMMA ] +## postfix_expression -> postfix_expression LBRACK expression . RBRACK [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## postfix_expression LBRACK expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +# We know for sure that an array subscript expression has begun, and +# a closing bracket is expected (if the expression is complete). +# The expression could also be completed with a COMMA, but there is +# no reason to mention that -- it can be viewed as part of the +# hypothesis "if the expression is complete". + +Ill-formed expression. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing bracket ']' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME LBRACK XOR_ASSIGN +## +## Ends in an error in state: 113. +## +## postfix_expression -> postfix_expression LBRACK . expression RBRACK [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## postfix_expression LBRACK +## + +Ill-formed expression. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 110. +## +## argument_expression_list -> argument_expression_list . COMMA assignment_expression [ RPAREN COMMA ] +## option(argument_expression_list) -> argument_expression_list . [ RPAREN ] +## +## The known suffix of the stack is as follows: +## argument_expression_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 109, spurious reduction of production argument_expression_list -> assignment_expression +## + +Up to this point, a list of expressions has been recognized: + $0 +If this list is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME LPAREN XOR_ASSIGN +## +## Ends in an error in state: 40. +## +## postfix_expression -> postfix_expression LPAREN . option(argument_expression_list) RPAREN [ XOR_ASSIGN SUB_ASSIGN STAR SLASH SEMICOLON RPAREN RIGHT_ASSIGN RIGHT RBRACK RBRACE QUESTION PTR PLUS PERCENT OR_ASSIGN NEQ MUL_ASSIGN MOD_ASSIGN MINUS LT LPAREN LEQ LEFT_ASSIGN LEFT LBRACK INC HAT GT GEQ EQEQ EQ DOT DIV_ASSIGN DEC COMMA COLON BARBAR BAR AND_ASSIGN ANDAND AND ADD_ASSIGN ] +## +## The known suffix of the stack is as follows: +## postfix_expression LPAREN +## + +# gcc and clang expect an expression: this is incomplete. + +Ill-formed expression. +At this point, a list of expressions, +followed with a closing parenthesis ')', is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME QUESTION VAR_NAME COLON XOR_ASSIGN +## +## Ends in an error in state: 101. +## +## conditional_expression -> logical_or_expression QUESTION expression COLON . conditional_expression [ SEMICOLON RPAREN RBRACK RBRACE COMMA COLON ] +## +## The known suffix of the stack is as follows: +## logical_or_expression QUESTION expression COLON +## +translation_unit_file: INT VAR_NAME EQ VAR_NAME QUESTION XOR_ASSIGN +## +## Ends in an error in state: 79. +## +## conditional_expression -> logical_or_expression QUESTION . expression COLON conditional_expression [ SEMICOLON RPAREN RBRACK RBRACE COMMA COLON ] +## +## The known suffix of the stack is as follows: +## logical_or_expression QUESTION +## + +Ill-formed conditional expression. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ VAR_NAME QUESTION VAR_NAME SEMICOLON +## +## Ends in an error in state: 97. +## +## conditional_expression -> logical_or_expression QUESTION expression . COLON conditional_expression [ SEMICOLON RPAREN RBRACK RBRACE COMMA COLON ] +## expression -> expression . COMMA assignment_expression [ COMMA COLON ] +## +## The known suffix of the stack is as follows: +## logical_or_expression QUESTION expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +# gcc and clang simply expect a colon. + +Ill-formed conditional expression. +Up to this point, an expression, '?', and an expression have been recognized: + $2 + $1 + $0 +If the last expression is complete, +then at this point, a colon ':' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: PACKED LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 343. +## +## argument_expression_list -> argument_expression_list . COMMA assignment_expression [ RPAREN COMMA ] +## attribute_specifier -> PACKED LPAREN argument_expression_list . RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## PACKED LPAREN argument_expression_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 109, spurious reduction of production argument_expression_list -> assignment_expression +## + +Ill-formed $2 attribute. +Up to this point, a list of expressions has been recognized: + $0 +If this list is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: PACKED LPAREN XOR_ASSIGN +## +## Ends in an error in state: 10. +## +## attribute_specifier -> PACKED LPAREN . argument_expression_list RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## PACKED LPAREN +## + +# clang expects a "parameter declarator" (?). +# gcc expects "declaration specifiers or ‘...’". +# Which is incorrect, since an ellipsis is rejected here. + +Ill-formed $1 attribute. +At this point, a list of expressions is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: PACKED XOR_ASSIGN +## +## Ends in an error in state: 9. +## +## attribute_specifier -> PACKED . LPAREN argument_expression_list RPAREN [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER RBRACK PLUS PACKED MINUS LPAREN LONG LBRACK LBRACE INT INLINE INC FLOAT EXTERN EQ ENUM DOUBLE DEC CONSTANT CONST COMMA COLON CHAR BUILTIN_VA_ARG BANG AUTO ATTRIBUTE AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## PACKED +## + +# This one seems important, since CompCert currently does not support __packed__ +# without an argument. + +Ill-formed $0 attribute. +At this point, an opening parenthesis '(', +followed with a possibly empty list of expressions, +is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 349. +## +## translation_unit -> translation_unit . external_declaration [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC SIGNED SHORT SEMICOLON RESTRICT REGISTER PRAGMA PACKED LONG INT INLINE FLOAT EXTERN EOF ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## translation_unit -> translation_unit . SEMICOLON [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC SIGNED SHORT SEMICOLON RESTRICT REGISTER PRAGMA PACKED LONG INT INLINE FLOAT EXTERN EOF ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## translation_unit_file -> translation_unit . EOF [ # ] +## +## The known suffix of the stack is as follows: +## translation_unit +## +translation_unit_file: XOR_ASSIGN +## +## Ends in an error in state: 0. +## +## translation_unit_file' -> . translation_unit_file [ # ] +## +## The known suffix of the stack is as follows: +## +## +# The king of all syntax errors: an error in the initial state. + +# Anyway, we are at the toplevel. + +# clang and gcc want an identifier or an opening parenthesis, which is way incomplete. + +At this point, one of the following is expected: + a function definition; or + a declaration; or + a pragma; or + the end of the file. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 356. +## +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: TYPEDEF_NAME TYPEDEF XOR_ASSIGN +## +## Ends in an error in state: 5. +## +## declaration_specifiers_typedef -> TYPEDEF_NAME list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## TYPEDEF_NAME list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) +## +translation_unit_file: VOLATILE TYPEDEF_NAME TYPEDEF XOR_ASSIGN +## +## Ends in an error in state: 367. +## +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) +## +translation_unit_file: TYPEDEF INT XOR_ASSIGN +## +## Ends in an error in state: 358. +## +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_typedef_name) -> list(declaration_specifier_no_typedef_name) . declaration_specifier_no_typedef_name [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT STATIC STAR SIGNED SHORT SEMICOLON RESTRICT REGISTER PACKED LPAREN LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) +## +translation_unit_file: INT TYPEDEF XOR_ASSIGN +## +## Ends in an error in state: 362. +## +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) TYPEDEF list(declaration_specifier_no_typedef_name) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_typedef_name) -> list(declaration_specifier_no_typedef_name) . declaration_specifier_no_typedef_name [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT STATIC STAR SIGNED SHORT SEMICOLON RESTRICT REGISTER PACKED LPAREN LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) TYPEDEF list(declaration_specifier_no_typedef_name) +## + +# We have begun a type definition (a.k.a. declaration_specifiers_typedef). +# To complete this type definition, +# we expect a possibly-empty list declaration_specifiers_no_type?, +# or declaration_specifiers_no_typedef_name?, +# (depending on which example sentence one looks at) +# which (in all cases) means a list of: +# storage class specifiers, +# type qualifiers, +# function specifiers (i.e., INLINE, but I suspect this is illegal here). +# and (in the second case) also includes: +# type_specifier_no_typedef_name (e.g., INT, etc.). +# After this type definition, +# we expect typedef_declarator_list? SEMICOLON. + +# We omit the possibility of giving another type specifier, such as INT. + +# We could omit the possibility of a storage class specifier and a type qualifier. + +# gcc and clang expect identifier or '(', which is correct but incomplete (and too low-level). + +Ill-formed type definition. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + a list of declarators, followed with a semicolon ';'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF XOR_ASSIGN +## +## Ends in an error in state: 354. +## +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) . TYPEDEF_NAME list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) . type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT STATIC SIGNED SHORT RESTRICT REGISTER PACKED LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) +## + +# We have seen the TYPEDEF keyword, and possibly some declaration_specifiers_no_type. +# We expect: +# possibly more declaration_specifiers_no_type?, +# which means a list of: +# storage class specifiers, +# type qualifiers, +# function specifiers (i.e., INLINE, but I suspect this is illegal here). +# followed with a type specifier. + +# gcc and clang expect identifier or '('. + +Ill-formed type definition. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + a type specifier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN VOLATILE XOR_ASSIGN +## +## Ends in an error in state: 257. +## +## declaration_specifiers(parameter_declaration) -> list(declaration_specifier_no_type) declaration_specifier_no_type . TYPEDEF_NAME list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR RPAREN LPAREN LBRACK COMMA ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) declaration_specifier_no_type . [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL STRUCT STATIC SIGNED SHORT RESTRICT REGISTER PACKED LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type +## + +# Analogous to the above, except we are in the context of a parameter declaration, +# and (obviously) have not seen a TYPEDEF keyword. +# We expect possibly more declaration_specifiers_no_type? +# followed with a type specifier. +# I think it is OK to forbid INLINE here. + +# (At this point, our declaration_specifiers will be complete, and the +# continuation would be declarator, abstract_declarator, or nothing, +# which implies COMMA or RPAREN. Let's not mention that, and describe +# things only up to the (required) type specifier.) + +Ill-formed parameter declaration. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + a type specifier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 2. +## +## declaration_specifiers(declaration(external_declaration)) -> TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> TYPEDEF_NAME list(declaration_specifier_no_type) . TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME TYPEDEF STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: VOLATILE TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 365. +## +## declaration_specifiers(declaration(external_declaration)) -> list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) . TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME TYPEDEF STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: INT XOR_ASSIGN +## +## Ends in an error in state: 360. +## +## declaration_specifiers(declaration(external_declaration)) -> list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) . TYPEDEF list(declaration_specifier_no_typedef_name) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_typedef_name) -> list(declaration_specifier_no_typedef_name) . declaration_specifier_no_typedef_name [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RESTRICT REGISTER PACKED LPAREN LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) +## + +# We have seen a TYPEDEF_NAME or a primitive type specifier, +# and possibly some declaration_specifiers_no_type. +# We expect: +# possibly more declaration_specifier_no_type or declaration_specifier_no_typedef_name, +# which means a list of: +# storage class specifiers, +# type qualifiers, +# function specifiers, +# possibly type specifiers, +# possibly followed with a TYPEDEF keyword. + +# Note that we can get here via spurious reductions (e.g. "enum foo" can +# be considered a complete enum_specifier, hence a complete type_specifier). +# Thus, the list of permitted continuations below can be slightly incomplete: +# an opening brace could be used to continue "enum foo". + +# Let's NOT mention the possibility of placing TYPEDEF somewhere in the middle. +# This means we pretend to be definitely in a declaration_specifiers(declaration). +# In other words, we are in the beginning of a declaration of function definition +# (we do not know which, yet). + +# Let's also ignore the possibility of writing INLINE *after* the result type, +# which sounds awkward. + +# If this declaration_specifiers is complete, +# then we expect: +# init_declarator_list? SEMICOLON if this is a declaration; +# ioption(pointer) x=direct_declarator if this is a function definition. +# (followed with a function body) + +# gcc and clang expect identifier or '(', which is very low-level. + +# We simplify "a list of init declarators" to "an init declarator". + +# Our message is probably too elaborate; we could omit certain elements, +# or try to simplify our description in the case of a function definition. + +Ill-formed declaration or function definition. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + an init declarator, + if this is a declaration; or + a possibly empty list of pointers, + followed with a direct declarator, + followed with a function body, + if this is a function definition. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 235. +## +## declaration_specifiers(parameter_declaration) -> TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR RPAREN LPAREN LBRACK COMMA ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME STATIC STAR RPAREN RESTRICT REGISTER PACKED LPAREN LBRACK INLINE EXTERN CONST COMMA AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: INT VAR_NAME LPAREN VOLATILE TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 259. +## +## declaration_specifiers(parameter_declaration) -> list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR RPAREN LPAREN LBRACK COMMA ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME STATIC STAR RPAREN RESTRICT REGISTER PACKED LPAREN LBRACK INLINE EXTERN CONST COMMA AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: INT VAR_NAME LPAREN INT XOR_ASSIGN +## +## Ends in an error in state: 250. +## +## declaration_specifiers(parameter_declaration) -> list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) . [ VAR_NAME TYPEDEF_NAME STAR RPAREN LPAREN LBRACK COMMA ] +## list(declaration_specifier_no_typedef_name) -> list(declaration_specifier_no_typedef_name) . declaration_specifier_no_typedef_name [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT STATIC STAR SIGNED SHORT RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) +## + +# Analogous to the above situation, except this time, we are in the +# context of a parameter declaration (as opposed to a declaration or +# function definition). This rules out 'typedef' and 'inline', for real, +# I think. Also, this changes the continuation. + +# We have seen a type specifier, +# and possibly some declaration_specifiers_no_type. +# We expect: +# possibly more declaration_specifier_no_type or declaration_specifier_no_typedef_name, +# which means a list of: +# storage class specifiers, +# type qualifiers. +# (omitting the possibility of another type specifier) + +# If this declaration_specifiers(parameter_declaration) is complete, +# then we expect: +# declarator +# abstract_declarator +# or neither, which means that the parameter_declaration is over, +# which means we expect COMMA or RPAREN. + +# We could say that $1 has been interpreted as a type specifier, +# although I don't know if that would help. + +# clang expects ')'. +# gcc expects ‘;’, ‘,’ or ‘)’. The semicolon seems incorrect. + +Ill-formed parameter declaration. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + a declarator; or + an abstract declarator; or + a comma ',', followed with a parameter declaration; or + a closing parenthesis ')'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: VOLATILE VAR_NAME +## +## Ends in an error in state: 363. +## +## declaration_specifiers(declaration(external_declaration)) -> list(declaration_specifier_no_type) declaration_specifier_no_type . TYPEDEF_NAME list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) declaration_specifier_no_type . TYPEDEF_NAME list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) declaration_specifier_no_type . [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF STRUCT STATIC SIGNED SHORT RESTRICT REGISTER PACKED LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type +## + +# We have seen some specifiers or qualifiers. We have probably seen at least +# one of them, otherwise we would be at the top level of the file, and the +# error would be signaled in another state, I think. + +# This could be the beginning of a declaration or function definition. + +# It could in theory be the beginning of a type definition, but only +# if the TYPEDEF keyword is not in front, which sounds awkward, so +# let's ignore that. + +# Again, we ignore the possibility of INLINE when not in front, as it +# is awkward. + +# We have not yet seen a type specifier, so we must see it, regardless +# of whether this is a declaration or function definition. + +Ill-formed declaration or function definition. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + a type specifier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE VOLATILE VAR_NAME +## +## Ends in an error in state: 424. +## +## declaration_specifiers(declaration(block_item)) -> list(declaration_specifier_no_type) declaration_specifier_no_type . TYPEDEF_NAME list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) declaration_specifier_no_type . TYPEDEF_NAME list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) declaration_specifier_no_type . [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF STRUCT STATIC SIGNED SHORT RESTRICT REGISTER PACKED LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type +## + +# Identical to the previous one, except we are not at the top level, +# so we know this cannot be the beginning of a function definition. + +Ill-formed declaration. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + a type specifier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE TYPEDEF_NAME VOLATILE XOR_ASSIGN +## +## Ends in an error in state: 393. +## +## declaration_specifiers(declaration(block_item)) -> TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> TYPEDEF_NAME list(declaration_specifier_no_type) . TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME TYPEDEF STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE VOLATILE TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 426. +## +## declaration_specifiers(declaration(block_item)) -> list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) . TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_type) -> list(declaration_specifier_no_type) . declaration_specifier_no_type [ VOLATILE VAR_NAME TYPEDEF_NAME TYPEDEF STATIC STAR SEMICOLON RESTRICT REGISTER PACKED LPAREN INLINE EXTERN CONST AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) declaration_specifier_no_type TYPEDEF_NAME list(declaration_specifier_no_type) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE INT XOR_ASSIGN +## +## Ends in an error in state: 423. +## +## declaration_specifiers(declaration(block_item)) -> list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) . [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) . TYPEDEF list(declaration_specifier_no_typedef_name) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## list(declaration_specifier_no_typedef_name) -> list(declaration_specifier_no_typedef_name) . declaration_specifier_no_typedef_name [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RESTRICT REGISTER PACKED LPAREN LONG INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(declaration_specifier_no_type) type_specifier_no_typedef_name list(declaration_specifier_no_typedef_name) +## + +# This is analogous to the error sentence TYPEDEF_NAME VOLATILE XOR_ASSIGN, +# except we are inside a block, instead of at the top level, so we +# know that this cannot be the beginning of a function definition. + +# This is an interesting situation where, by using phantom parameters, +# we have forced a distinction between two states that would NOT be +# distinguished in a canonical automaton. Indeed, the lookahead sets +# are the same: the states would be the same if the phantom parameters +# were erased. + +# Assuming that the list of init declarators is nonempty, we say that +# we expect an init declarator, instead of saying that we expect a +# possibly empty, comma-separated list of init declarators, followed +# with a semicolon. + +# We do not distinguish the case where we have seen a primitive type +# specifier, so another primitive type specifier would be OK. + +# gcc and clang expect identifier or '(', which is incomplete and low-level. + +Ill-formed declaration. +At this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + an init declarator. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 225. +## +## struct_declaration -> specifier_qualifier_list(struct_declaration) . option(struct_declarator_list) SEMICOLON [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT SIGNED SHORT RESTRICT RBRACE PACKED LONG INT FLOAT ENUM DOUBLE CONST CHAR ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## specifier_qualifier_list(struct_declaration) +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 313, spurious reduction of production specifier_qualifier_list(struct_declaration) -> option(type_qualifier_list) TYPEDEF_NAME option(type_qualifier_list) +## + +# We have (spuriously) recognized a specifier_qualifier_list, +# part of a struct_declaration. +# Thus, we expect: +# more type qualifiers or specifiers (part of the specifier_qualifier_list), or +# a struct declarator, or +# a semicolon. + +# The nonterminal symbol is officially called struct-declaration. +# But this means struct *or union*, +# and it is a declaration of a struct or union *member*. + +# It seems good to show the type specifier that we have just read (if +# there is one), as it could be a variable name that has been +# mis-classified as a type name, I suppose. + +# clang's message is analogous to ours. +# gcc expects identifier or '('. + +Ill-formed struct declaration. +Up to this point, +a list of type qualifiers and type specifiers has been recognized: + $0 +If this list is complete, then +at this point, one of the following is expected: + a struct declarator; or + a semicolon ';'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE LONG COLON CONSTANT RPAREN +## +## Ends in an error in state: 301. +## +## option(struct_declarator_list) -> struct_declarator_list . [ SEMICOLON ] +## struct_declarator_list -> struct_declarator_list . COMMA struct_declarator [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## struct_declarator_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 31, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 306, spurious reduction of production struct_declarator -> option(declarator) COLON conditional_expression +## In state 308, spurious reduction of production struct_declarator_list -> struct_declarator +## + +# We have seen a non-empty struct_declarator_list. + +# clang expects a semicolon, like us. +# gcc expects too many things (incorrect). + +Ill-formed struct declaration. +Up to this point, a list of struct declarators has been recognized: + $0 +If this list is complete, +then at this point, a semicolon ';' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE INT COLON XOR_ASSIGN +## +## Ends in an error in state: 305. +## +## struct_declarator -> option(declarator) COLON . conditional_expression [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## option(declarator) COLON +## + +Ill-formed struct declarator. +At this point, a constant expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE INT VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 302. +## +## struct_declarator_list -> struct_declarator_list COMMA . struct_declarator [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## struct_declarator_list COMMA +## + +Ill-formed struct declaration. +At this point, a struct declarator is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE INT VAR_NAME RPAREN +## +## Ends in an error in state: 307. +## +## option(declarator) -> declarator . [ COLON ] +## struct_declarator -> declarator . [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## declarator +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 275, spurious reduction of production attribute_specifier_list -> +## In state 281, spurious reduction of production declarator -> direct_declarator attribute_specifier_list +## + +# Assuming the declarator so far is complete, we expect +# either COLON constant_expression (part of this struct_declarator) +# or something that follows this struct_declarator. + +# clang expects ';'. +# gcc expects many things, including '}', which seems incorrect. + +Ill-formed struct declaration. +Up to this point, a declarator has been recognized: + $0 +If this declarator is complete, +then at this point, one of the following is expected: + a colon ':', followed with a constant expression; or + a comma ',', followed with a struct declarator; or + a semicolon ';'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE VOLATILE ADD_ASSIGN +## +## Ends in an error in state: 311. +## +## specifier_qualifier_list(struct_declaration) -> option(type_qualifier_list) . TYPEDEF_NAME option(type_qualifier_list) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN COLON ] +## specifier_qualifier_list(struct_declaration) -> option(type_qualifier_list) . type_specifier_no_typedef_name list(specifier_qualifier_no_typedef_name) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN COLON ] +## type_qualifier_list -> option(type_qualifier_list) . type_qualifier [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT SIGNED SHORT RESTRICT PACKED LONG INT FLOAT ENUM DOUBLE CONST CHAR ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## option(type_qualifier_list) +## + +# A list of qualifiers has been read. +# (Probably a nonempty list, otherwise we would be in a different state.) +# We expect a type specifier, or one more qualifier. + +Ill-formed struct declaration. +At this point, one of the following is expected: + a type qualifier; or + a type specifier. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION LBRACE XOR_ASSIGN +## +## Ends in an error in state: 222. +## +## struct_declaration_list -> struct_declaration_list . struct_declaration [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME STRUCT SIGNED SHORT RESTRICT RBRACE PACKED LONG INT FLOAT ENUM DOUBLE CONST CHAR ATTRIBUTE ALIGNAS ] +## struct_or_union_specifier -> struct_or_union attribute_specifier_list option(other_identifier) LBRACE struct_declaration_list . RBRACE [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## struct_or_union attribute_specifier_list option(other_identifier) LBRACE struct_declaration_list +## + +# gcc and clang do not seem prepared to accept a struct or union with +# zero members, so they request a type specifier or qualifier. + +At this point, one of the following is expected: + a struct declaration; or + a closing brace '}'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: UNION XOR_ASSIGN +## +## Ends in an error in state: 219. +## +## attribute_specifier_list -> attribute_specifier_list . attribute_specifier [ VAR_NAME TYPEDEF_NAME PACKED LBRACE ATTRIBUTE ALIGNAS ] +## struct_or_union_specifier -> struct_or_union attribute_specifier_list . option(other_identifier) LBRACE struct_declaration_list RBRACE [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## struct_or_union_specifier -> struct_or_union attribute_specifier_list . general_identifier [ VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC STAR SIGNED SHORT SEMICOLON RPAREN RESTRICT REGISTER PACKED LPAREN LONG LBRACK INT INLINE FLOAT EXTERN ENUM DOUBLE CONST COMMA COLON CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## struct_or_union attribute_specifier_list +## + +# gcc expects '{'. +# clang gives a mysterious message: "declaration of anonymous union must be a definition". +# Adding TYPEDEF in front does not help. + +Ill-formed struct or union specifier. +At this point, one of the following is expected: + an attribute specifier; or + an identifier; or + an opening brace '{', followed with a list of members. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 283. +## +## direct_declarator -> LPAREN declarator . RPAREN [ SEMICOLON RPAREN PACKED LPAREN LBRACK LBRACE EQ COMMA COLON ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## LPAREN declarator +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 275, spurious reduction of production attribute_specifier_list -> +## In state 281, spurious reduction of production declarator -> direct_declarator attribute_specifier_list +## + +Up to this point, an opening parenthesis and a declarator have been recognized: + $1 $0 +If this declarator is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT LPAREN XOR_ASSIGN +## +## Ends in an error in state: 226. +## +## direct_declarator -> LPAREN . declarator RPAREN [ SEMICOLON RPAREN PACKED LPAREN LBRACK LBRACE EQ COMMA COLON ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## LPAREN +## + +# clang and gcc expect identifier or '(', as usual. + +Ill-formed direct declarator. +At this point, a declarator is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT STAR RPAREN +## +## Ends in an error in state: 658. +## +## declarator -> list(pointer1) STAR option(type_qualifier_list) . direct_declarator attribute_specifier_list [ SEMICOLON EQ COMMA ] +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) . direct_declarator [ LBRACE ] +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) . direct_declarator LPAREN identifier_list RPAREN open_context declaration_list [ LBRACE ] +## list(pointer1) -> list(pointer1) STAR option(type_qualifier_list) . [ STAR ] +## type_qualifier_list -> option(type_qualifier_list) . type_qualifier [ VOLATILE VAR_NAME TYPEDEF_NAME STAR RESTRICT PACKED LPAREN CONST ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) +## + +# We are definitely at the beginning of a function definition, and have seen +# a return type (declaration_specifiers) and a pointer1 (i.e. at least one STAR). +# Here, either this pointer could be continued, or we expect a direct_declarator. + +# clang and gcc expect identifier or '(', as usual. + +Ill-formed function definition. +At this point, one of the following is expected: + a type qualifier; or + a star '*', possibly followed with type qualifiers; or + a direct declarator. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT STAR VAR_NAME LPAREN VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 662. +## +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) direct_declarator LPAREN identifier_list . RPAREN open_context declaration_list [ LBRACE ] +## identifier_list -> identifier_list . COMMA VAR_NAME [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) direct_declarator LPAREN identifier_list +## +translation_unit_file: INT VAR_NAME LPAREN VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 671. +## +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) direct_declarator LPAREN identifier_list . RPAREN open_context declaration_list [ LBRACE ] +## identifier_list -> identifier_list . COMMA VAR_NAME [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) direct_declarator LPAREN identifier_list +## + +Ill-formed K&R function definition. +Up to this point, a list of identifiers has been recognized: + $0 +If this list is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT STAR VAR_NAME LPAREN XOR_ASSIGN +## +## Ends in an error in state: 660. +## +## direct_declarator -> direct_declarator LPAREN . open_context option(parameter_type_list) save_contexts_stk close_context RPAREN [ SEMICOLON PACKED LPAREN LBRACK LBRACE EQ COMMA ATTRIBUTE ALIGNAS ] +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) direct_declarator LPAREN . identifier_list RPAREN open_context declaration_list [ LBRACE ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) direct_declarator LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN XOR_ASSIGN +## +## Ends in an error in state: 670. +## +## direct_declarator -> direct_declarator LPAREN . open_context option(parameter_type_list) save_contexts_stk close_context RPAREN [ SEMICOLON PACKED LPAREN LBRACK LBRACE EQ COMMA ATTRIBUTE ALIGNAS ] +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) direct_declarator LPAREN . identifier_list RPAREN open_context declaration_list [ LBRACE ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) direct_declarator LPAREN +## + +# Ignore K&R syntax, just request ANSI syntax. +# Ignore the distinction between parameter-type-list and parameter-list. + +# clang expects a parameter declarator (which is incomplete). +# gcc expects declaration specifiers or ‘...’ (which is incorrect). + +Ill-formed function definition. +At this point, a list of parameter declarations, +followed with a closing parenthesis ')', is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF INT STAR RPAREN +## +## Ends in an error in state: 229. +## +## declarator -> list(pointer1) STAR option(type_qualifier_list) . direct_declarator attribute_specifier_list [ SEMICOLON RPAREN EQ COMMA COLON ] +## list(pointer1) -> list(pointer1) STAR option(type_qualifier_list) . [ STAR ] +## type_qualifier_list -> option(type_qualifier_list) . type_qualifier [ VOLATILE VAR_NAME TYPEDEF_NAME STAR RESTRICT PACKED LPAREN CONST ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## list(pointer1) STAR option(type_qualifier_list) +## + +# If the pointer isn't finished, we expect +# one more type qualifier; or +# one more '*', possibly followed with type qualifiers. +# If the pointer is finished, then we expect a direct declarator. + +# If may seem tempting to declare --on-error-reduce "list(pointer1)", but +# that would clash with --on-error-reduce "abstract_declarator(type_name)". +# There are states where both reductions are enabled, and Menhir currently +# refuses to choose between them. + +# clang and gcc expect identifier or '(', as usual. + +Ill-formed declarator. +At this point, one of the following is expected: + a type qualifier; or + a star '*', possibly followed with type qualifiers; or + a direct declarator. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF INT VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 515. +## +## option(typedef_declarator_list) -> typedef_declarator_list . [ SEMICOLON ] +## typedef_declarator_list -> typedef_declarator_list . COMMA typedef_declarator [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## typedef_declarator_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 275, spurious reduction of production attribute_specifier_list -> +## In state 281, spurious reduction of production declarator -> direct_declarator attribute_specifier_list +## In state 519, spurious reduction of production declare_typename(fst(declarator)) -> declarator +## In state 518, spurious reduction of production typedef_declarator -> declare_typename(fst(declarator)) +## In state 520, spurious reduction of production typedef_declarator_list -> typedef_declarator +## + +# Because attribute_specifier_list and declarator have been marked +# --on-error-reduce, we perform several spurious reductions and end up here. +# Which is good, because the context is clear. + +# If the attribute_specifier_list or declarator was not finished, then we could have accepted: +# an attribute specifier. +# a opening bracket '['. +# an opening parenthesis '('. + +# As far as the C grammar is concerned, typedef_declarator is just declarator. + +# clang says "invalid token after top level declarator", which seems vague. +# gcc expects a list of many things... + +Up to this point, a list of declarators has been recognized: + $0 +If this list is complete, +then at this point, a semicolon ';' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF INT VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 516. +## +## typedef_declarator_list -> typedef_declarator_list COMMA . typedef_declarator [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## typedef_declarator_list COMMA +## + +At this point, a declarator is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: TYPEDEF INT VAR_NAME LPAREN XOR_ASSIGN +## +## Ends in an error in state: 233. +## +## direct_declarator -> direct_declarator LPAREN open_context . option(parameter_type_list) save_contexts_stk close_context RPAREN [ SEMICOLON RPAREN PACKED LPAREN LBRACK LBRACE EQ COMMA COLON ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## direct_declarator LPAREN open_context +## +translation_unit_file: ALIGNAS LPAREN INT LPAREN RPAREN LPAREN XOR_ASSIGN +## +## Ends in an error in state: 262. +## +## in_context(option(parameter_type_list)) -> open_context . option(parameter_type_list) close_context [ RPAREN ] +## +## The known suffix of the stack is as follows: +## open_context +## + +At this point, a list of parameter declarations, +followed with a closing parenthesis ')', is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM CONST XOR_ASSIGN +## +## Ends in an error in state: 453. +## +## asm_attributes -> CONST . asm_attributes [ LPAREN ] +## +## The known suffix of the stack is as follows: +## CONST +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM VOLATILE XOR_ASSIGN +## +## Ends in an error in state: 452. +## +## asm_attributes -> VOLATILE . asm_attributes [ LPAREN ] +## +## The known suffix of the stack is as follows: +## VOLATILE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM XOR_ASSIGN +## +## Ends in an error in state: 613. +## +## asm_statement(nop) -> ASM . asm_attributes LPAREN string_literals_list asm_arguments RPAREN SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ASM +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO ASM XOR_ASSIGN +## +## Ends in an error in state: 451. +## +## asm_statement(close_context) -> ASM . asm_attributes LPAREN string_literals_list asm_arguments RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ASM +## + +# TEMPORARY maybe 'const' does not make sense here; gcc and clang ignore it; check. + +Ill-formed assembly statement. +At this point, one of the following is expected: + an assembly attribute, such as 'const' or 'volatile'; or + an opening parenthesis '('. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON COLON COLON STRING_LITERAL COMMA XOR_ASSIGN +## +## Ends in an error in state: 477. +## +## asm_flags -> asm_flags COMMA . string_literals_list [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## asm_flags COMMA +## +# We are in the clobber list. +# We have seen a comma, so we expect a string literal. +# first(asm_flags) = STRING_LITERAL +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON COLON COLON XOR_ASSIGN +## +## Ends in an error in state: 474. +## +## asm_arguments -> COLON asm_operands COLON asm_operands COLON . asm_flags [ RPAREN ] +## +## The known suffix of the stack is as follows: +## COLON asm_operands COLON asm_operands COLON +## +# We are at the beginning of the clobber list. +# first(asm_flags) = STRING_LITERAL + +Ill-formed assembly statement. +At this point, a clobbered resource is expected. +Examples of clobbered resources: + "memory" + "eax" + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON COLON COLON STRING_LITERAL XOR_ASSIGN +## +## Ends in an error in state: 476. +## +## asm_arguments -> COLON asm_operands COLON asm_operands COLON asm_flags . [ RPAREN ] +## asm_flags -> asm_flags . COMMA string_literals_list [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## COLON asm_operands COLON asm_operands COLON asm_flags +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 475, spurious reduction of production asm_flags -> string_literals_list +## + +# Let's ignore the possibility of concatenating string literals. +# We are in the clobber list (asm_flags). +# Either we extend it, or we terminate it with RPAREN. + +Ill-formed assembly statement. +Up to this point, a list of clobbered resources has been recognized: + $0 +If this list is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON STRING_LITERAL LPAREN CONSTANT RPAREN XOR_ASSIGN +## +## Ends in an error in state: 471. +## +## asm_arguments -> COLON asm_operands . [ RPAREN ] +## asm_arguments -> COLON asm_operands . COLON asm_operands [ RPAREN ] +## asm_arguments -> COLON asm_operands . COLON asm_operands COLON asm_flags [ RPAREN ] +## +## The known suffix of the stack is as follows: +## COLON asm_operands +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 463, spurious reduction of production asm_operands -> asm_operands_ne +## + +# We have seen one COLON, hence the outputs. (The list of outputs may be empty.) + +# TEMPORARY the grammar allows a list of outputs, but the documentation allows at most one output. + +Ill-formed assembly statement. +Up to this point, a list of outputs has been recognized: + $0 +If this list is complete, +then at this point, one of the following is expected: + a colon ':', followed with a list of inputs; or + a closing parenthesis ')'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON COLON XOR_ASSIGN +## +## Ends in an error in state: 473. +## +## asm_arguments -> COLON asm_operands COLON asm_operands . [ RPAREN ] +## asm_arguments -> COLON asm_operands COLON asm_operands . COLON asm_flags [ RPAREN ] +## +## The known suffix of the stack is as follows: +## COLON asm_operands COLON asm_operands +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 472, spurious reduction of production asm_operands -> +## + +# We have seen two COLONs, hence the outputs and inputs. (The list of inputs may be empty.) + +# clang requests a closing parenthesis. gcc requests a string literal. + +Ill-formed assembly statement. +Up to this point, a list of outputs and a list of inputs have been recognized: + $2 + $0 +If the latter list is complete, +then at this point, one of the following is expected: + a colon ':', followed with a list of clobbered resources; or + a closing parenthesis ')'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON LBRACK VAR_NAME RBRACK XOR_ASSIGN +## +## Ends in an error in state: 466. +## +## asm_operand -> asm_op_name . string_literals_list LPAREN expression RPAREN [ RPAREN COMMA COLON ] +## +## The known suffix of the stack is as follows: +## asm_op_name +## + +# Example of asm_operand: [oldval]"=r"(res) +# We have seen an asm_op_name, we now expect a string literal list. +# "=r" is an example of a constraint. + +Ill-formed assembly operand. +At this point, a string literal, representing a constraint, is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON LBRACK VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 461. +## +## asm_op_name -> LBRACK general_identifier . RBRACK [ STRING_LITERAL ] +## +## The known suffix of the stack is as follows: +## LBRACK general_identifier +## + +Ill-formed assembly operand. +At this point, a closing bracket ']' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON LBRACK XOR_ASSIGN +## +## Ends in an error in state: 460. +## +## asm_op_name -> LBRACK . general_identifier RBRACK [ STRING_LITERAL ] +## +## The known suffix of the stack is as follows: +## LBRACK +## + +Ill-formed assembly operand. +At this point, an identifier is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON STRING_LITERAL LPAREN CONSTANT RPAREN COMMA XOR_ASSIGN +## +## Ends in an error in state: 464. +## +## asm_operands_ne -> asm_operands_ne COMMA . asm_operand [ RPAREN COMMA COLON ] +## +## The known suffix of the stack is as follows: +## asm_operands_ne COMMA +## + +# clang and gcc request a string literal (which is incomplete). + +Ill-formed assembly statement. +At this point, an assembly operand is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON STRING_LITERAL LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 469. +## +## asm_operand -> asm_op_name string_literals_list LPAREN expression . RPAREN [ RPAREN COMMA COLON ] +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## asm_op_name string_literals_list LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +Ill-formed assembly operand. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON STRING_LITERAL LPAREN XOR_ASSIGN +## +## Ends in an error in state: 468. +## +## asm_operand -> asm_op_name string_literals_list LPAREN . expression RPAREN [ RPAREN COMMA COLON ] +## +## The known suffix of the stack is as follows: +## asm_op_name string_literals_list LPAREN +## + +Ill-formed assembly operand. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL COLON STRING_LITERAL XOR_ASSIGN +## +## Ends in an error in state: 467. +## +## asm_operand -> asm_op_name string_literals_list . LPAREN expression RPAREN [ RPAREN COMMA COLON ] +## string_literals_list -> string_literals_list . STRING_LITERAL [ STRING_LITERAL LPAREN ] +## +## The known suffix of the stack is as follows: +## asm_op_name string_literals_list +## + +# If we disregard the concatenation of string literals, then +# at this point, we expect LPAREN. + +Ill-formed assembly operand. +At this point, an opening parenthesis '(', +followed with an expression and a closing parenthesis ')', is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL XOR_ASSIGN +## +## Ends in an error in state: 616. +## +## asm_statement(nop) -> ASM asm_attributes LPAREN string_literals_list . asm_arguments RPAREN SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## string_literals_list -> string_literals_list . STRING_LITERAL [ STRING_LITERAL RPAREN COLON ] +## +## The known suffix of the stack is as follows: +## ASM asm_attributes LPAREN string_literals_list +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO ASM LPAREN STRING_LITERAL XOR_ASSIGN +## +## Ends in an error in state: 458. +## +## asm_statement(close_context) -> ASM asm_attributes LPAREN string_literals_list . asm_arguments RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## string_literals_list -> string_literals_list . STRING_LITERAL [ STRING_LITERAL RPAREN COLON ] +## +## The known suffix of the stack is as follows: +## ASM asm_attributes LPAREN string_literals_list +## + +# Expecting either one more string literal, or COLON, or RPAREN. + +# clang requests ')'. gcc requests ':' or ')'. + +Ill-formed assembly statement. +At this point, one of the following is expected: + a string literal, representing one more instruction; or + a colon ':', followed with a list of outputs; or + a closing parenthesis ')'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN XOR_ASSIGN +## +## Ends in an error in state: 615. +## +## asm_statement(nop) -> ASM asm_attributes LPAREN . string_literals_list asm_arguments RPAREN SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ASM asm_attributes LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO ASM LPAREN XOR_ASSIGN +## +## Ends in an error in state: 457. +## +## asm_statement(close_context) -> ASM asm_attributes LPAREN . string_literals_list asm_arguments RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ASM asm_attributes LPAREN +## + +Ill-formed assembly statement. +At this point, a string literal, representing an instruction, is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE BREAK XOR_ASSIGN +## +## Ends in an error in state: 611. +## +## jump_statement(nop) -> BREAK . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## BREAK +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO BREAK XOR_ASSIGN +## +## Ends in an error in state: 449. +## +## jump_statement(close_context) -> BREAK close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## BREAK close_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE CONTINUE XOR_ASSIGN +## +## Ends in an error in state: 606. +## +## jump_statement(nop) -> CONTINUE . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CONTINUE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO CONTINUE XOR_ASSIGN +## +## Ends in an error in state: 443. +## +## jump_statement(close_context) -> CONTINUE close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CONTINUE close_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SEMICOLON WHILE LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 602. +## +## iteration_statement(open_context,statement_finish_close) -> DO open_context statement_finish_close WHILE open_context LPAREN expression RPAREN close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE open_context LPAREN expression RPAREN close_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DO SEMICOLON WHILE LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 507. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE LPAREN expression RPAREN close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE LPAREN expression RPAREN close_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE GOTO VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 585. +## +## jump_statement(nop) -> GOTO general_identifier . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## GOTO general_identifier +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO GOTO VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 414. +## +## jump_statement(close_context) -> GOTO general_identifier close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## GOTO general_identifier close_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DO SEMICOLON WHILE LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 539. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE LPAREN expression RPAREN close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> DO open_context statement_finish_close WHILE LPAREN expression RPAREN close_context . SEMICOLON [ ELSE ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE LPAREN expression RPAREN close_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE ASM LPAREN STRING_LITERAL RPAREN XOR_ASSIGN +## +## Ends in an error in state: 618. +## +## asm_statement(nop) -> ASM asm_attributes LPAREN string_literals_list asm_arguments RPAREN . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ASM asm_attributes LPAREN string_literals_list asm_arguments RPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO ASM LPAREN STRING_LITERAL RPAREN XOR_ASSIGN +## +## Ends in an error in state: 482. +## +## asm_statement(close_context) -> ASM asm_attributes LPAREN string_literals_list asm_arguments RPAREN close_context . SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## ASM asm_attributes LPAREN string_literals_list asm_arguments RPAREN close_context +## + +Ill-formed statement. +At this point, a semicolon ';' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE CASE CONSTANT COLON XOR_ASSIGN +## +## Ends in an error in state: 610. +## +## labeled_statement(statement_finish_noclose) -> CASE conditional_expression COLON . statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CASE conditional_expression COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DEFAULT COLON XOR_ASSIGN +## +## Ends in an error in state: 605. +## +## labeled_statement(statement_finish_noclose) -> DEFAULT COLON . statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DEFAULT COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN CASE CONSTANT COLON XOR_ASSIGN +## +## Ends in an error in state: 545. +## +## labeled_statement(statement_finish_close) -> CASE conditional_expression COLON . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> CASE conditional_expression COLON . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## CASE conditional_expression COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO CASE CONSTANT COLON XOR_ASSIGN +## +## Ends in an error in state: 447. +## +## labeled_statement(statement_finish_close) -> CASE conditional_expression COLON . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CASE conditional_expression COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DEFAULT COLON XOR_ASSIGN +## +## Ends in an error in state: 542. +## +## labeled_statement(statement_finish_close) -> DEFAULT COLON . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> DEFAULT COLON . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## DEFAULT COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DEFAULT COLON XOR_ASSIGN +## +## Ends in an error in state: 441. +## +## labeled_statement(statement_finish_close) -> DEFAULT COLON . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DEFAULT COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN VAR_NAME COLON XOR_ASSIGN +## +## Ends in an error in state: 555. +## +## labeled_statement(statement_finish_close) -> general_identifier COLON . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> general_identifier COLON . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## general_identifier COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE VAR_NAME COLON XOR_ASSIGN +## +## Ends in an error in state: 631. +## +## labeled_statement(statement_finish_noclose) -> general_identifier COLON . statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## general_identifier COLON +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO VAR_NAME COLON XOR_ASSIGN +## +## Ends in an error in state: 496. +## +## labeled_statement(statement_finish_close) -> general_identifier COLON . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## general_identifier COLON +## + +# gcc and clang request an expression, which seems misleading (incomplete). + +Ill-formed labeled statement. +At this point, a statement is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE CASE CONSTANT SEMICOLON +## +## Ends in an error in state: 609. +## +## labeled_statement(statement_finish_noclose) -> CASE conditional_expression . COLON statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CASE conditional_expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 31, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN CASE CONSTANT SEMICOLON +## +## Ends in an error in state: 544. +## +## labeled_statement(statement_finish_close) -> CASE conditional_expression . COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> CASE conditional_expression . COLON statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## CASE conditional_expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 31, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO CASE CONSTANT SEMICOLON +## +## Ends in an error in state: 446. +## +## labeled_statement(statement_finish_close) -> CASE conditional_expression . COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CASE conditional_expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 31, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## + +Ill-formed labeled statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a colon ':' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE CASE XOR_ASSIGN +## +## Ends in an error in state: 608. +## +## labeled_statement(statement_finish_noclose) -> CASE . conditional_expression COLON statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CASE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN CASE XOR_ASSIGN +## +## Ends in an error in state: 543. +## +## labeled_statement(statement_finish_close) -> CASE . conditional_expression COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> CASE . conditional_expression COLON statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## CASE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO CASE XOR_ASSIGN +## +## Ends in an error in state: 445. +## +## labeled_statement(statement_finish_close) -> CASE . conditional_expression COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## CASE +## + +Ill-formed labeled statement. +At this point, a constant expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DEFAULT XOR_ASSIGN +## +## Ends in an error in state: 604. +## +## labeled_statement(statement_finish_noclose) -> DEFAULT . COLON statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DEFAULT +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 495. +## +## labeled_statement(statement_finish_close) -> general_identifier . COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## general_identifier +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DEFAULT XOR_ASSIGN +## +## Ends in an error in state: 541. +## +## labeled_statement(statement_finish_close) -> DEFAULT . COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> DEFAULT . COLON statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## DEFAULT +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 554. +## +## labeled_statement(statement_finish_close) -> general_identifier . COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## labeled_statement(statement_intern_close) -> general_identifier . COLON statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## general_identifier +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE VAR_NAME COLON TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 630. +## +## labeled_statement(statement_finish_noclose) -> general_identifier . COLON statement_finish_noclose [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## general_identifier +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DEFAULT XOR_ASSIGN +## +## Ends in an error in state: 440. +## +## labeled_statement(statement_finish_close) -> DEFAULT . COLON statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DEFAULT +## + +# gcc and clang apparently do not allow a TYPEDEF_NAME to be reclassified as a label. + +Ill-formed labeled statement. +At this point, a colon ':' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SEMICOLON WHILE LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 600. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## iteration_statement(open_context,statement_finish_close) -> DO open_context statement_finish_close WHILE open_context LPAREN expression . RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE open_context LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DO SEMICOLON WHILE LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 537. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE LPAREN expression . RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> DO open_context statement_finish_close WHILE LPAREN expression . RPAREN close_context SEMICOLON [ ELSE ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DO SEMICOLON WHILE LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 505. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE LPAREN expression . RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +Ill-formed 'do' ... 'while' statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' and a semicolon ';' are expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SEMICOLON WHILE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 599. +## +## iteration_statement(open_context,statement_finish_close) -> DO open_context statement_finish_close WHILE open_context LPAREN . expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE open_context LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DO SEMICOLON WHILE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 536. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE LPAREN . expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> DO open_context statement_finish_close WHILE LPAREN . expression RPAREN close_context SEMICOLON [ ELSE ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DO SEMICOLON WHILE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 504. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE LPAREN . expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE LPAREN +## + +Ill-formed 'do' ... 'while' statement. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SEMICOLON WHILE XOR_ASSIGN +## +## Ends in an error in state: 598. +## +## iteration_statement(open_context,statement_finish_close) -> DO open_context statement_finish_close WHILE open_context . LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE open_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DO SEMICOLON WHILE XOR_ASSIGN +## +## Ends in an error in state: 535. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE . LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> DO open_context statement_finish_close WHILE . LPAREN expression RPAREN close_context SEMICOLON [ ELSE ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DO SEMICOLON WHILE XOR_ASSIGN +## +## Ends in an error in state: 503. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close WHILE . LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close WHILE +## + +Ill-formed 'do' ... 'while' statement. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 596. +## +## iteration_statement(open_context,statement_finish_close) -> DO open_context statement_finish_close . WHILE open_context LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DO SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 534. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close . WHILE LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> DO open_context statement_finish_close . WHILE LPAREN expression RPAREN close_context SEMICOLON [ ELSE ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DO SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 502. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context statement_finish_close . WHILE LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context statement_finish_close +## + +# Quite nicely, in this case, there is no doubt that the statement is +# finished. This is not true in general, I think (the statement could +# be an if/then, and we don't know whether it should have an ELSE +# branch) but is true sometimes (e.g. it is not a conditional +# statement, or it is one and we just saw the ELSE branch). + +Ill-formed 'do' ... 'while' statement. +At this point, a 'while' keyword is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO XOR_ASSIGN +## +## Ends in an error in state: 595. +## +## iteration_statement(open_context,statement_finish_close) -> DO open_context . statement_finish_close WHILE open_context LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN DO XOR_ASSIGN +## +## Ends in an error in state: 432. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context . statement_finish_close WHILE LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> DO open_context . statement_finish_close WHILE LPAREN expression RPAREN close_context SEMICOLON [ ELSE ] +## +## The known suffix of the stack is as follows: +## DO open_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO DO XOR_ASSIGN +## +## Ends in an error in state: 439. +## +## iteration_statement(nop,statement_finish_close) -> DO open_context . statement_finish_close WHILE LPAREN expression RPAREN close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## DO open_context +## + +# gcc and clang expect an expression. + +Ill-formed 'do' ... 'while' statement. +At this point, a statement (the loop body) is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR LPAREN SEMICOLON SEMICOLON RPAREN XOR_ASSIGN +## +## Ends in an error in state: 592. +## +## iteration_statement(open_context,statement_finish_close) -> FOR open_context LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR open_context LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN FOR LPAREN SEMICOLON SEMICOLON RPAREN XOR_ASSIGN +## +## Ends in an error in state: 430. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> FOR LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO FOR LPAREN SEMICOLON SEMICOLON RPAREN XOR_ASSIGN +## +## Ends in an error in state: 437. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) +## + +Ill-formed 'for' statement. +At this point, a statement (the loop body) is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR LPAREN SEMICOLON SEMICOLON VAR_NAME SEMICOLON +## +## Ends in an error in state: 510. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## optional(expression,RPAREN) -> expression . RPAREN [ WHILE VAR_NAME TYPEDEF_NAME TILDE SWITCH STRING_LITERAL STAR SIZEOF SEMICOLON RETURN PLUS MINUS LPAREN LBRACE INC IF GOTO FOR DO DEFAULT DEC CONTINUE CONSTANT CASE BUILTIN_VA_ARG BREAK BANG ASM AND ALIGNOF ] +## +## The known suffix of the stack is as follows: +## expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +# The use of optional(expression,RPAREN) tells us that we are in a FOR statement. +# Relying on this is a bit fragile, though. + +Ill-formed 'for' statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR LPAREN SEMICOLON SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 591. +## +## iteration_statement(open_context,statement_finish_close) -> FOR open_context LPAREN for_statement_header optional(expression,SEMICOLON) . optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR open_context LPAREN for_statement_header optional(expression,SEMICOLON) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN FOR LPAREN SEMICOLON SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 428. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN for_statement_header optional(expression,SEMICOLON) . optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> FOR LPAREN for_statement_header optional(expression,SEMICOLON) . optional(expression,RPAREN) statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN for_statement_header optional(expression,SEMICOLON) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO FOR LPAREN SEMICOLON SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 436. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN for_statement_header optional(expression,SEMICOLON) . optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN for_statement_header optional(expression,SEMICOLON) +## + +# Expecting the third part of the loop header -- the expression +# that tells what happens after each iteration. + +Ill-formed 'for' statement. +At this point, an optional expression + (evaluated after each execution of the loop body), +followed with a closing parenthesis ')', is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR LPAREN SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 590. +## +## iteration_statement(open_context,statement_finish_close) -> FOR open_context LPAREN for_statement_header . optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR open_context LPAREN for_statement_header +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN FOR LPAREN SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 427. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN for_statement_header . optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> FOR LPAREN for_statement_header . optional(expression,SEMICOLON) optional(expression,RPAREN) statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN for_statement_header +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO FOR LPAREN SEMICOLON XOR_ASSIGN +## +## Ends in an error in state: 435. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN for_statement_header . optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN for_statement_header +## + +# Expecting the second part of the loop header -- the controlling expression. + +Ill-formed 'for' statement. +At this point, an optional expression + (evaluated before each execution of the loop body), +followed with a semicolon ';', is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR LPAREN VAR_NAME RPAREN +## +## Ends in an error in state: 512. +## +## expression -> expression . COMMA assignment_expression [ SEMICOLON COMMA ] +## optional(expression,SEMICOLON) -> expression . SEMICOLON [ VAR_NAME TILDE STRING_LITERAL STAR SIZEOF SEMICOLON RPAREN PLUS MINUS LPAREN INC DEC CONSTANT BUILTIN_VA_ARG BANG AND ALIGNOF ] +## +## The known suffix of the stack is as follows: +## expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +# At the time of writing, optional(expression,SEMICOLON) is used only in FOR +# loops, but it could be used elsewhere in the future. This is a bit fragile. + +Ill-formed 'for' statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a semicolon ';' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR LPAREN XOR_ASSIGN +## +## Ends in an error in state: 589. +## +## iteration_statement(open_context,statement_finish_close) -> FOR open_context LPAREN . for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR open_context LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN FOR LPAREN XOR_ASSIGN +## +## Ends in an error in state: 417. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN . for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> FOR LPAREN . for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO FOR LPAREN XOR_ASSIGN +## +## Ends in an error in state: 434. +## +## iteration_statement(nop,statement_finish_close) -> FOR LPAREN . for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR LPAREN +## + +# gcc and clang say they expect an expression, which is incomplete. + +Ill-formed 'for' statement. +At this point, one of the following is expected: + an optional expression + (evaluated once at the beginning), + followed with a semicolon ';'; or + a declaration. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE FOR XOR_ASSIGN +## +## Ends in an error in state: 588. +## +## iteration_statement(open_context,statement_finish_close) -> FOR open_context . LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR open_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN FOR XOR_ASSIGN +## +## Ends in an error in state: 416. +## +## iteration_statement(nop,statement_finish_close) -> FOR . LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> FOR . LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## FOR +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO FOR XOR_ASSIGN +## +## Ends in an error in state: 433. +## +## iteration_statement(nop,statement_finish_close) -> FOR . LPAREN for_statement_header optional(expression,SEMICOLON) optional(expression,RPAREN) statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## FOR +## + +Ill-formed 'for' statement. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE GOTO XOR_ASSIGN +## +## Ends in an error in state: 584. +## +## jump_statement(nop) -> GOTO . general_identifier SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## GOTO +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO GOTO XOR_ASSIGN +## +## Ends in an error in state: 412. +## +## jump_statement(close_context) -> GOTO . general_identifier close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## GOTO +## + +Ill-formed 'goto' statement. +At this point, an identifier (a 'goto' label) is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN SEMICOLON ELSE XOR_ASSIGN +## +## Ends in an error in state: 628. +## +## selection_statement_finish(open_context) -> if_else_statement_begin(open_context) ELSE . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## if_else_statement_begin(open_context) ELSE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN IF LPAREN VAR_NAME RPAREN SEMICOLON ELSE XOR_ASSIGN +## +## Ends in an error in state: 552. +## +## selection_statement_finish(nop) -> if_else_statement_begin(nop) ELSE . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## selection_statement_intern_close -> if_else_statement_begin(nop) ELSE . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## if_else_statement_begin(nop) ELSE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO IF LPAREN CONSTANT RPAREN SEMICOLON ELSE XOR_ASSIGN +## +## Ends in an error in state: 493. +## +## selection_statement_finish(nop) -> if_else_statement_begin(nop) ELSE . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## if_else_statement_begin(nop) ELSE +## + +Ill-formed 'if' ... 'else' statement. +At this point, a statement is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN IF LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 403. +## +## if_else_statement_begin(nop) -> IF LPAREN expression RPAREN save_contexts_stk . statement_intern_close [ ELSE ] +## selection_statement_finish(nop) -> IF LPAREN expression RPAREN save_contexts_stk . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF LPAREN expression RPAREN save_contexts_stk +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 581. +## +## if_else_statement_begin(open_context) -> IF open_context LPAREN expression RPAREN save_contexts_stk . statement_intern_close [ ELSE ] +## selection_statement_finish(open_context) -> IF open_context LPAREN expression RPAREN save_contexts_stk . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF open_context LPAREN expression RPAREN save_contexts_stk +## + +Ill-formed 'if' statement. +At this point, a statement is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN IF LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 401. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## if_else_statement_begin(nop) -> IF LPAREN expression . RPAREN save_contexts_stk statement_intern_close [ ELSE ] +## selection_statement_finish(nop) -> IF LPAREN expression . RPAREN save_contexts_stk statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 579. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## if_else_statement_begin(open_context) -> IF open_context LPAREN expression . RPAREN save_contexts_stk statement_intern_close [ ELSE ] +## selection_statement_finish(open_context) -> IF open_context LPAREN expression . RPAREN save_contexts_stk statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF open_context LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +Ill-formed 'if' statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN IF LPAREN XOR_ASSIGN +## +## Ends in an error in state: 400. +## +## if_else_statement_begin(nop) -> IF LPAREN . expression RPAREN save_contexts_stk statement_intern_close [ ELSE ] +## selection_statement_finish(nop) -> IF LPAREN . expression RPAREN save_contexts_stk statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN XOR_ASSIGN +## +## Ends in an error in state: 578. +## +## if_else_statement_begin(open_context) -> IF open_context LPAREN . expression RPAREN save_contexts_stk statement_intern_close [ ELSE ] +## selection_statement_finish(open_context) -> IF open_context LPAREN . expression RPAREN save_contexts_stk statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF open_context LPAREN +## + +Ill-formed 'if' statement. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN IF XOR_ASSIGN +## +## Ends in an error in state: 399. +## +## if_else_statement_begin(nop) -> IF . LPAREN expression RPAREN save_contexts_stk statement_intern_close [ ELSE ] +## selection_statement_finish(nop) -> IF . LPAREN expression RPAREN save_contexts_stk statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF XOR_ASSIGN +## +## Ends in an error in state: 577. +## +## if_else_statement_begin(open_context) -> IF open_context . LPAREN expression RPAREN save_contexts_stk statement_intern_close [ ELSE ] +## selection_statement_finish(open_context) -> IF open_context . LPAREN expression RPAREN save_contexts_stk statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## IF open_context +## + +Ill-formed 'if' statement. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN SWITCH LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 411. +## +## selection_statement_finish(nop) -> SWITCH LPAREN expression RPAREN . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## selection_statement_intern_close -> SWITCH LPAREN expression RPAREN . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## SWITCH LPAREN expression RPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE SWITCH LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 398. +## +## selection_statement_finish(open_context) -> SWITCH open_context LPAREN expression RPAREN . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH open_context LPAREN expression RPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SWITCH LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 384. +## +## selection_statement_finish(nop) -> SWITCH LPAREN expression RPAREN . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH LPAREN expression RPAREN +## + +# Technically, the body of a 'switch' statement is just a statement, +# but in practice, it should be a list of labeled statements, +# enclosed in braces. (Unless someone is writing a Duff loop...) + +# gcc and clang again request an expression... + +Ill-formed 'switch' statement. +At this point, a statement is expected. +It usually takes the form of a series of labeled statements, +enclosed within braces '{' and '}'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN SWITCH LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 410. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## selection_statement_finish(nop) -> SWITCH LPAREN expression . RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## selection_statement_intern_close -> SWITCH LPAREN expression . RPAREN statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## SWITCH LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE SWITCH LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 397. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## selection_statement_finish(open_context) -> SWITCH open_context LPAREN expression . RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH open_context LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SWITCH LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 383. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## selection_statement_finish(nop) -> SWITCH LPAREN expression . RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +Ill-formed 'switch' statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN SWITCH LPAREN XOR_ASSIGN +## +## Ends in an error in state: 409. +## +## selection_statement_finish(nop) -> SWITCH LPAREN . expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## selection_statement_intern_close -> SWITCH LPAREN . expression RPAREN statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## SWITCH LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE SWITCH LPAREN XOR_ASSIGN +## +## Ends in an error in state: 396. +## +## selection_statement_finish(open_context) -> SWITCH open_context LPAREN . expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH open_context LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SWITCH LPAREN XOR_ASSIGN +## +## Ends in an error in state: 382. +## +## selection_statement_finish(nop) -> SWITCH LPAREN . expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH LPAREN +## + +Ill-formed 'switch' statement. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN SWITCH XOR_ASSIGN +## +## Ends in an error in state: 408. +## +## selection_statement_finish(nop) -> SWITCH . LPAREN expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## selection_statement_intern_close -> SWITCH . LPAREN expression RPAREN statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## SWITCH +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE SWITCH XOR_ASSIGN +## +## Ends in an error in state: 395. +## +## selection_statement_finish(open_context) -> SWITCH open_context . LPAREN expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH open_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO SWITCH XOR_ASSIGN +## +## Ends in an error in state: 381. +## +## selection_statement_finish(nop) -> SWITCH . LPAREN expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## SWITCH +## + +Ill-formed 'switch' statement. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN WHILE LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 407. +## +## iteration_statement(nop,statement_finish_close) -> WHILE LPAREN expression RPAREN . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> WHILE LPAREN expression RPAREN . statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## WHILE LPAREN expression RPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE WHILE LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 375. +## +## iteration_statement(open_context,statement_finish_close) -> WHILE open_context LPAREN expression RPAREN . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE open_context LPAREN expression RPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO WHILE LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 379. +## +## iteration_statement(nop,statement_finish_close) -> WHILE LPAREN expression RPAREN . statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE LPAREN expression RPAREN +## + +Ill-formed 'while' statement. +At this point, a statement (the loop body) is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN WHILE LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 406. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## iteration_statement(nop,statement_finish_close) -> WHILE LPAREN expression . RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> WHILE LPAREN expression . RPAREN statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## WHILE LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE WHILE LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 374. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## iteration_statement(open_context,statement_finish_close) -> WHILE open_context LPAREN expression . RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE open_context LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO WHILE LPAREN VAR_NAME SEMICOLON +## +## Ends in an error in state: 378. +## +## expression -> expression . COMMA assignment_expression [ RPAREN COMMA ] +## iteration_statement(nop,statement_finish_close) -> WHILE LPAREN expression . RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE LPAREN expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +Ill-formed 'while' statement. +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN WHILE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 405. +## +## iteration_statement(nop,statement_finish_close) -> WHILE LPAREN . expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> WHILE LPAREN . expression RPAREN statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## WHILE LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE WHILE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 373. +## +## iteration_statement(open_context,statement_finish_close) -> WHILE open_context LPAREN . expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE open_context LPAREN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO WHILE LPAREN XOR_ASSIGN +## +## Ends in an error in state: 377. +## +## iteration_statement(nop,statement_finish_close) -> WHILE LPAREN . expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE LPAREN +## + +Ill-formed 'while' statement. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE IF LPAREN VAR_NAME RPAREN WHILE XOR_ASSIGN +## +## Ends in an error in state: 404. +## +## iteration_statement(nop,statement_finish_close) -> WHILE . LPAREN expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## iteration_statement(nop,statement_intern_close) -> WHILE . LPAREN expression RPAREN statement_intern_close [ ELSE ] +## +## The known suffix of the stack is as follows: +## WHILE +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE WHILE XOR_ASSIGN +## +## Ends in an error in state: 372. +## +## iteration_statement(open_context,statement_finish_close) -> WHILE open_context . LPAREN expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE open_context +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO WHILE XOR_ASSIGN +## +## Ends in an error in state: 376. +## +## iteration_statement(nop,statement_finish_close) -> WHILE . LPAREN expression RPAREN statement_finish_close [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## WHILE +## + +Ill-formed 'while' statement. +At this point, an opening parenthesis '(' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE LBRACE XOR_ASSIGN +## +## Ends in an error in state: 575. +## +## block_item_list -> option(block_item_list) . block_item [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## compound_statement(open_context) -> LBRACE open_context option(block_item_list) . close_context RBRACE [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## LBRACE open_context option(block_item_list) +## +# We are possibly at the end of a block. +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO LBRACE XOR_ASSIGN +## +## Ends in an error in state: 391. +## +## block_item_list -> option(block_item_list) . block_item [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## compound_statement(nop) -> LBRACE option(block_item_list) . close_context RBRACE [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## LBRACE option(block_item_list) +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE XOR_ASSIGN +## +## Ends in an error in state: 370. +## +## block_item_list -> option(block_item_list) . block_item [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## function_definition -> function_definition_begin LBRACE option(block_item_list) . close_context RBRACE [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC SIGNED SHORT SEMICOLON RESTRICT REGISTER PRAGMA PACKED LONG INT INLINE FLOAT EXTERN EOF ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## function_definition_begin LBRACE option(block_item_list) +## +# We are possibly at the end of a function body. +# +# Note that, because we have used --on-error-reduce to consider some statements +# as complete even when they could be continued ELSE, we may end up here even +# though ELSE is permitted. There is nothing we can do about it. We just omit +# this permitted continuation in our message. + +# clang and gcc say an expression is expected. + +At this point, one of the following is expected: + a declaration; or + a statement; or + a pragma; or + a closing brace '}'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE RETURN XOR_ASSIGN +## +## Ends in an error in state: 569. +## +## jump_statement(nop) -> RETURN . option(expression) SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## RETURN +## +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE DO RETURN XOR_ASSIGN +## +## Ends in an error in state: 385. +## +## jump_statement(close_context) -> RETURN . option(expression) close_context SEMICOLON [ WHILE VOLATILE VOID VAR_NAME UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF TILDE SWITCH STRUCT STRING_LITERAL STATIC STAR SIZEOF SIGNED SHORT SEMICOLON RETURN RESTRICT REGISTER RBRACE PRAGMA PLUS PACKED MINUS LPAREN LONG LBRACE INT INLINE INC IF GOTO FOR FLOAT EXTERN ENUM ELSE DOUBLE DO DEFAULT DEC CONTINUE CONSTANT CONST CHAR CASE BUILTIN_VA_ARG BREAK BANG AUTO ATTRIBUTE ASM AND ALIGNOF ALIGNAS ] +## +## The known suffix of the stack is as follows: +## RETURN +## + +# clang and gcc expect an expression. + +Ill-formed 'return' statement. +At this point, one of the following is expected: + an expression; or + a semicolon ';'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE STRING_LITERAL RPAREN +## +## Ends in an error in state: 389. +## +## expression -> expression . COMMA assignment_expression [ SEMICOLON COMMA ] +## option(expression) -> expression . [ SEMICOLON ] +## +## The known suffix of the stack is as follows: +## expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 32, spurious reduction of production primary_expression -> string_literals_list +## In state 34, spurious reduction of production postfix_expression -> primary_expression +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 103, spurious reduction of production expression -> assignment_expression +## + +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a semicolon ';' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE TYPEDEF_NAME XOR_ASSIGN +## +## Ends in an error in state: 392. +## +## declaration_specifiers(declaration(block_item)) -> TYPEDEF_NAME . list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## declaration_specifiers_typedef -> TYPEDEF_NAME . list(declaration_specifier_no_type) TYPEDEF list(declaration_specifier_no_type) [ VAR_NAME TYPEDEF_NAME STAR SEMICOLON LPAREN ] +## general_identifier -> TYPEDEF_NAME . [ COLON ] +## +## The known suffix of the stack is as follows: +## TYPEDEF_NAME +## + +# We see a type name "foo" at the beginning of a block_item, it seems. +# This could be the beginning of a declaration, "foo x". +# In that case, we expect a possibly-empty list declaration_specifiers_no_type?, +# which means a list of: +# storage class specifiers, +# type qualifiers, +# function specifiers (i.e., INLINE, but I suspect this is illegal here). +# After this list, we expect init_declarator_list? SEMICOLON. +# The second form, where this could be a typedef, is very exotic; ignore it. +# This could also be a labeled statement, in which case we expect a colon. +# This case sounds rather unlikely. Let's omit it. + +# We simplify "a list of init declarators" to "an init declarator". + +A type identifier has been recognized. +Assuming this is the beginning of a declaration, +at this point, one of the following is expected: + a storage class specifier; or + a type qualifier; or + an init declarator, followed with a semicolon ';'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME RPAREN LBRACE VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 98. +## +## expression -> expression COMMA . assignment_expression [ SEMICOLON RPAREN RBRACK COMMA COLON ] +## +## The known suffix of the stack is as follows: +## expression COMMA +## + +Ill-formed use of the sequencing operator ','. +At this point, an expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME COMMA VAR_NAME RPAREN +## +## Ends in an error in state: 526. +## +## init_declarator_list -> init_declarator_list . COMMA init_declarator [ SEMICOLON COMMA ] +## option(init_declarator_list) -> init_declarator_list . [ SEMICOLON ] +## +## The known suffix of the stack is as follows: +## init_declarator_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 275, spurious reduction of production attribute_specifier_list -> +## In state 281, spurious reduction of production declarator -> direct_declarator attribute_specifier_list +## In state 294, spurious reduction of production declare_varname(fst(declarator)) -> declarator +## In state 529, spurious reduction of production init_declarator -> declare_varname(fst(declarator)) +## In state 528, spurious reduction of production init_declarator_list -> init_declarator_list COMMA init_declarator +## + +Up to this point, a list of declarators has been recognized: + $0 +If this list is complete, +then at this point, a semicolon ';' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 527. +## +## init_declarator_list -> init_declarator_list COMMA . init_declarator [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## init_declarator_list COMMA +## + +Ill-formed declaration. +At this point, an init declarator is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE DOT VAR_NAME EQ ALIGNAS +## +## Ends in an error in state: 132. +## +## initializer_list -> option(designation) . c_initializer [ RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## option(designation) +## +translation_unit_file: INT VAR_NAME EQ LBRACE VAR_NAME COMMA DOT VAR_NAME EQ ALIGNAS +## +## Ends in an error in state: 136. +## +## initializer_list -> initializer_list COMMA option(designation) . c_initializer [ RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## initializer_list COMMA option(designation) +## + +Ill-formed initializer list. +At this point, an initializer is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE DOT VAR_NAME XOR_ASSIGN +## +## Ends in an error in state: 139. +## +## designation -> designator_list . EQ [ VAR_NAME TILDE STRING_LITERAL STAR SIZEOF PLUS MINUS LPAREN LBRACE INC DEC CONSTANT BUILTIN_VA_ARG BANG AND ALIGNOF ] +## option(designator_list) -> designator_list . [ LBRACK DOT ] +## +## The known suffix of the stack is as follows: +## designator_list +## + +# We are expecting either one more designator, +# or an EQ sign (which marks the end of the designation). + +Ill-formed designation. +Up to this point, a list of designators has been recognized: + $0 +If this list is complete, +then at this point, an equals sign '=' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE DOT XOR_ASSIGN +## +## Ends in an error in state: 129. +## +## designator -> DOT . general_identifier [ LBRACK EQ DOT ] +## +## The known suffix of the stack is as follows: +## DOT +## + +# clang gives examples of designators. + +Ill-formed designator. +At this point, the name of a struct or union member is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE LBRACK VAR_NAME SEMICOLON +## +## Ends in an error in state: 127. +## +## designator -> LBRACK conditional_expression . RBRACK [ LBRACK EQ DOT ] +## +## The known suffix of the stack is as follows: +## LBRACK conditional_expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 31, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## + +Ill-formed designator. +Up to this point, an opening bracket and an expression have been recognized: + $1 $0 +If this expression is complete, +then at this point, a closing bracket ']' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE LBRACK XOR_ASSIGN +## +## Ends in an error in state: 126. +## +## designator -> LBRACK . conditional_expression RBRACK [ LBRACK EQ DOT ] +## +## The known suffix of the stack is as follows: +## LBRACK +## + +Ill-formed designator. +At this point, a constant expression is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 135. +## +## initializer_list -> initializer_list COMMA . option(designation) c_initializer [ RBRACE COMMA ] +## option(COMMA) -> COMMA . [ RBRACE ] +## +## The known suffix of the stack is as follows: +## initializer_list COMMA +## + +# This could be a trailing comma, in which case a closing brace is legal. +# Or, this comma could announce a new option(designation) c_initializer. + +Ill-formed initializer list. +At this point, one of the following is expected: + an optional designation, followed with an initializer; or + a closing brace '}'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE CONSTANT SEMICOLON +## +## Ends in an error in state: 134. +## +## c_initializer -> LBRACE initializer_list . option(COMMA) RBRACE [ SEMICOLON RBRACE COMMA ] +## initializer_list -> initializer_list . COMMA option(designation) c_initializer [ RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## LBRACE initializer_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## In state 138, spurious reduction of production c_initializer -> assignment_expression +## In state 144, spurious reduction of production initializer_list -> option(designation) c_initializer +## + +# Omitting the fact that the closing brace can be preceded with a comma. + +Ill-formed initializer. +Up to this point, a list of initializers has been recognized: + $0 +If this list is complete, +then at this point, a closing brace '}' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ LBRACE XOR_ASSIGN +## +## Ends in an error in state: 133. +## +## c_initializer -> LBRACE . initializer_list option(COMMA) RBRACE [ SEMICOLON RBRACE COMMA ] +## +## The known suffix of the stack is as follows: +## LBRACE +## + +# An initializer list is expected. +# Hence, an initializer is expected. + +# clang and gcc expect an expression (incomplete). + +Ill-formed initializer. +At this point, an optional designation, +followed with an initializer, is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME EQ XOR_ASSIGN +## +## Ends in an error in state: 530. +## +## init_declarator -> declare_varname(fst(declarator)) EQ . c_initializer [ SEMICOLON COMMA ] +## +## The known suffix of the stack is as follows: +## declare_varname(fst(declarator)) EQ +## + +# clang and gcc expect an expression (incomplete). + +Ill-formed init declarator. +At this point, an initializer is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LBRACK CONSTANT SEMICOLON +## +## Ends in an error in state: 279. +## +## optional(assignment_expression,RBRACK) -> assignment_expression . RBRACK [ SEMICOLON RPAREN PACKED LPAREN LBRACK LBRACE EQ COMMA COLON ATTRIBUTE ALIGNAS ] +## +## The known suffix of the stack is as follows: +## assignment_expression +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 35, spurious reduction of production unary_expression -> postfix_expression +## In state 41, spurious reduction of production cast_expression -> unary_expression +## In state 64, spurious reduction of production multiplicative_expression -> cast_expression +## In state 58, spurious reduction of production additive_expression -> multiplicative_expression +## In state 77, spurious reduction of production shift_expression -> additive_expression +## In state 54, spurious reduction of production relational_expression -> shift_expression +## In state 70, spurious reduction of production equality_expression -> relational_expression +## In state 86, spurious reduction of production and_expression -> equality_expression +## In state 94, spurious reduction of production exclusive_or_expression -> and_expression +## In state 95, spurious reduction of production inclusive_or_expression -> exclusive_or_expression +## In state 96, spurious reduction of production logical_and_expression -> inclusive_or_expression +## In state 80, spurious reduction of production logical_or_expression -> logical_and_expression +## In state 78, spurious reduction of production conditional_expression -> logical_or_expression +## In state 99, spurious reduction of production assignment_expression -> conditional_expression +## + +# At the time of writing, optional(expression,RBRACK) is used only in direct +# (possibly abstract) declarators, but it could be used elsewhere in the future. +# This is a bit fragile. + +# Ill-formed direct declarator or direct abstract declarator. + +Up to this point, an expression has been recognized: + $0 +If this expression is complete, +then at this point, a closing bracket ']' is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN VAR_NAME COMMA XOR_ASSIGN +## +## Ends in an error in state: 667. +## +## identifier_list -> identifier_list COMMA . VAR_NAME [ RPAREN COMMA ] +## +## The known suffix of the stack is as follows: +## identifier_list COMMA +## + +# Strangely, gcc requests ')'. + +Ill-formed K&R function definition. +At this point, an identifier is expected. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 674. +## +## declaration_list -> declaration_list . declaration(block_item) [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC SIGNED SHORT RESTRICT REGISTER PACKED LONG LBRACE INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) direct_declarator LPAREN identifier_list RPAREN open_context declaration_list . [ LBRACE ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) direct_declarator LPAREN identifier_list RPAREN open_context declaration_list +## +translation_unit_file: INT STAR VAR_NAME LPAREN VAR_NAME RPAREN XOR_ASSIGN +## +## Ends in an error in state: 665. +## +## declaration_list -> declaration_list . declaration(block_item) [ VOLATILE VOID UNSIGNED UNION UNDERSCORE_BOOL TYPEDEF_NAME TYPEDEF STRUCT STATIC SIGNED SHORT RESTRICT REGISTER PACKED LONG LBRACE INT INLINE FLOAT EXTERN ENUM DOUBLE CONST CHAR AUTO ATTRIBUTE ALIGNAS ] +## function_definition_begin -> declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) direct_declarator LPAREN identifier_list RPAREN open_context declaration_list . [ LBRACE ] +## +## The known suffix of the stack is as follows: +## declaration_specifiers(declaration(external_declaration)) list(pointer1) STAR option(type_qualifier_list) direct_declarator LPAREN identifier_list RPAREN open_context declaration_list +## + +# clang requests the function body; gcc requests a declaration :-) + +Ill-formed K&R function definition. +At this point, one of the following is expected: + a declaration; or + an opening brace '{' (for the function body). + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT COMMA XOR_ASSIGN +## +## Ends in an error in state: 245. +## +## parameter_list -> parameter_list COMMA . parameter_declaration [ RPAREN COMMA ] +## parameter_type_list -> parameter_list COMMA . ELLIPSIS [ RPAREN ] +## +## The known suffix of the stack is as follows: +## parameter_list COMMA +## + +At this point, one of the following is expected: + a parameter declaration; or + an ellipsis '...'. + +# ------------------------------------------------------------------------------ + +translation_unit_file: INT VAR_NAME LPAREN INT VAR_NAME SEMICOLON +## +## Ends in an error in state: 244. +## +## parameter_list -> parameter_list . COMMA parameter_declaration [ RPAREN COMMA ] +## parameter_type_list -> parameter_list . [ RPAREN ] +## parameter_type_list -> parameter_list . COMMA ELLIPSIS [ RPAREN ] +## +## The known suffix of the stack is as follows: +## parameter_list +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 275, spurious reduction of production attribute_specifier_list -> +## In state 281, spurious reduction of production declarator -> direct_declarator attribute_specifier_list +## In state 294, spurious reduction of production declare_varname(fst(declarator)) -> declarator +## In state 293, spurious reduction of production parameter_declaration -> declaration_specifiers(parameter_declaration) declare_varname(fst(declarator)) +## In state 263, spurious reduction of production parameter_list -> parameter_declaration +## + +# We omit the possibility of an ellipsis. +# It can be understood as part of the "if this list is complete..." hypothesis. + +# Strangely, gcc is not bothered by the last SEMICOLON, +# but complains that this is a "forward declaration" of the parameter. + +Up to this point, a list of parameter declarations has been recognized: + $0 +If this list is complete, +then at this point, a closing parenthesis ')' is expected. + +# ------------------------------------------------------------------------------ + +# Local Variables: +# mode: shell-script +# End: diff --git a/cparser/tests/generated/Makefile b/cparser/tests/generated/Makefile new file mode 100644 index 00000000..12a65e11 --- /dev/null +++ b/cparser/tests/generated/Makefile @@ -0,0 +1,38 @@ +.PHONY: all clean + +SOURCES := $(wildcard *.c) +TARGETS := \ + $(patsubst %.c,%.ccomp.err,$(SOURCES)) \ + $(patsubst %.c,%.gcc.err,$(SOURCES)) \ + $(patsubst %.c,%.clang.err,$(SOURCES)) + +CCOMP := ../../../ccomp +GCC := gcc +CLANG := clang + +all: $(TARGETS) + +clean: + @ rm -f *.err *~ + +%.ccomp.err: %.c $(CCOMP) + @ echo $(CCOMP) -c $< + @ if $(CCOMP) -c $< 2>$@ ; then \ + echo "UNEXPECTED SUCCESS: $(CCOMP) -c $< SUCCEEDED!" ; \ + fi + @ if grep "unknown syntax error" $@ ; then \ + echo "UNKNOWN SYNTAX ERROR!" ; \ + fi + +%.gcc.err: %.c + @ echo $(GCC) -c $< + @ if $(GCC) -c $< 2>$@ ; then \ + echo "UNEXPECTED SUCCESS: $(GCC) -c $< SUCCEEDED!" ; \ + fi + +%.clang.err: %.c + @ echo $(CLANG) -c $< + @ if $(CLANG) -c $< 2>$@ ; then \ + echo "UNEXPECTED SUCCESS: $(CLANG) -c $< SUCCEEDED!" ; \ + fi + -- cgit From dd95046b3d6bb6603529e20f2d15b14fe4144a94 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:45:27 +0200 Subject: Added some handwritten .c files in tests/handwritten/. --- cparser/tests/handwritten/conditional-0.c | 4 ++++ cparser/tests/handwritten/conditional-1.c | 4 ++++ cparser/tests/handwritten/dubious-enum.c | 7 +++++++ cparser/tests/handwritten/missing-assignment.c | 4 ++++ .../handwritten/missing-closing-brace-at-end-of-function.c | 10 ++++++++++ cparser/tests/handwritten/missing-loop-body.c | 5 +++++ cparser/tests/handwritten/missing-operator.c | 5 +++++ cparser/tests/handwritten/missing-semicolon.c | 5 +++++ cparser/tests/handwritten/too-many-closing-parens.c | 4 ++++ cparser/tests/handwritten/unclosed-paren.c | 5 +++++ cparser/tests/handwritten/variable-type-confusion.c | 6 ++++++ 11 files changed, 59 insertions(+) create mode 100644 cparser/tests/handwritten/conditional-0.c create mode 100644 cparser/tests/handwritten/conditional-1.c create mode 100644 cparser/tests/handwritten/dubious-enum.c create mode 100644 cparser/tests/handwritten/missing-assignment.c create mode 100644 cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c create mode 100644 cparser/tests/handwritten/missing-loop-body.c create mode 100644 cparser/tests/handwritten/missing-operator.c create mode 100644 cparser/tests/handwritten/missing-semicolon.c create mode 100644 cparser/tests/handwritten/too-many-closing-parens.c create mode 100644 cparser/tests/handwritten/unclosed-paren.c create mode 100644 cparser/tests/handwritten/variable-type-confusion.c diff --git a/cparser/tests/handwritten/conditional-0.c b/cparser/tests/handwritten/conditional-0.c new file mode 100644 index 00000000..4aeb4659 --- /dev/null +++ b/cparser/tests/handwritten/conditional-0.c @@ -0,0 +1,4 @@ +int main (int x, int y) +{ + return x == 0 ? x : y == 0 : y; +} diff --git a/cparser/tests/handwritten/conditional-1.c b/cparser/tests/handwritten/conditional-1.c new file mode 100644 index 00000000..c6a5210a --- /dev/null +++ b/cparser/tests/handwritten/conditional-1.c @@ -0,0 +1,4 @@ +int main (int x, int y) +{ + return x == 0 ? x : y == 0 ? y; +} diff --git a/cparser/tests/handwritten/dubious-enum.c b/cparser/tests/handwritten/dubious-enum.c new file mode 100644 index 00000000..12ee6683 --- /dev/null +++ b/cparser/tests/handwritten/dubious-enum.c @@ -0,0 +1,7 @@ +int f (void) +{ + int x = sizeof(enum e; + /* Maybe a closing parenthesis is missing, + maybe also "enum e" could be continued with an opening brace. + Our message ignores the latter possibility. */ +} diff --git a/cparser/tests/handwritten/missing-assignment.c b/cparser/tests/handwritten/missing-assignment.c new file mode 100644 index 00000000..2fce2cbf --- /dev/null +++ b/cparser/tests/handwritten/missing-assignment.c @@ -0,0 +1,4 @@ +int main (void) +{ + int x = 10, y 8; +} diff --git a/cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c b/cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c new file mode 100644 index 00000000..dfb3691d --- /dev/null +++ b/cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c @@ -0,0 +1,10 @@ +int main (void) +{ + int x = 0; + x++; + /* missing closing brace, here */ + /* unfortunately, the error is detected only after the declaration of f */ + +void f (void) +{ +} diff --git a/cparser/tests/handwritten/missing-loop-body.c b/cparser/tests/handwritten/missing-loop-body.c new file mode 100644 index 00000000..44781564 --- /dev/null +++ b/cparser/tests/handwritten/missing-loop-body.c @@ -0,0 +1,5 @@ +int main (void) +{ + int x = 10; + while (x--) /* missing loop body */ +} diff --git a/cparser/tests/handwritten/missing-operator.c b/cparser/tests/handwritten/missing-operator.c new file mode 100644 index 00000000..d93e91f4 --- /dev/null +++ b/cparser/tests/handwritten/missing-operator.c @@ -0,0 +1,5 @@ +int main (void) +{ + int y = 7, z = 8; + int x = (3 * (2 x) - y * y); +} diff --git a/cparser/tests/handwritten/missing-semicolon.c b/cparser/tests/handwritten/missing-semicolon.c new file mode 100644 index 00000000..a655ca3b --- /dev/null +++ b/cparser/tests/handwritten/missing-semicolon.c @@ -0,0 +1,5 @@ +int main (void) +{ + int y = 7, z = 8 + int x = (3 * (2 + x) - y * y); +} diff --git a/cparser/tests/handwritten/too-many-closing-parens.c b/cparser/tests/handwritten/too-many-closing-parens.c new file mode 100644 index 00000000..68fe0b62 --- /dev/null +++ b/cparser/tests/handwritten/too-many-closing-parens.c @@ -0,0 +1,4 @@ +int main (void) +{ + int x = main()); +} diff --git a/cparser/tests/handwritten/unclosed-paren.c b/cparser/tests/handwritten/unclosed-paren.c new file mode 100644 index 00000000..b0ef6747 --- /dev/null +++ b/cparser/tests/handwritten/unclosed-paren.c @@ -0,0 +1,5 @@ +int main (void) +{ + int y = 7; + int x = (3 * (2 + x) - y * y; +} diff --git a/cparser/tests/handwritten/variable-type-confusion.c b/cparser/tests/handwritten/variable-type-confusion.c new file mode 100644 index 00000000..0957ca9d --- /dev/null +++ b/cparser/tests/handwritten/variable-type-confusion.c @@ -0,0 +1,6 @@ +typedef int t; +typedef int u; +int f (void) { + t = 3; +} + -- cgit From 08575b87304810f6c1a75ab10186636836b57613 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:51:12 +0200 Subject: Added a few cleanup commands in [make clean]. --- Makefile.extr | 3 ++- cparser/GNUmakefile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.extr b/Makefile.extr index fce0d933..4e2549cc 100644 --- a/Makefile.extr +++ b/Makefile.extr @@ -165,7 +165,8 @@ clean: rm -f $(EXECUTABLES) rm -f $(GENERATED) for d in $(ALLDIRS); do rm -f $$d/*.cm[iox] $$d/*.o; done - rm -f cparser/pre_parser.automaton backend/CMparser.automaton + rm -f backend/CMparser.automaton + $(MAKE) -C cparser clean # Generation of .depend.extr diff --git a/cparser/GNUmakefile b/cparser/GNUmakefile index 6c1df250..d08ef178 100644 --- a/cparser/GNUmakefile +++ b/cparser/GNUmakefile @@ -170,6 +170,6 @@ clean: rm -f pre_parser.automaton rm -f pre_parser.conflicts rm -f pre_parser.messages - rm -f $(DATABASE).raw + rm -f $(DATABASE).raw $(DATABASE).bak rm -f deLexer -- cgit From 1f74fdf503d3c501d2e261e76337452f6401d63a Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 13:59:40 +0200 Subject: Added copyright banners to the new files. --- Makefile.menhir | 12 ++++++++++++ cparser/ErrorReports.ml | 15 +++++++++++++++ cparser/ErrorReports.mli | 15 +++++++++++++++ cparser/GNUmakefile | 12 ++++++++++++ cparser/deLexer.ml | 15 +++++++++++++++ cparser/handcrafted.messages | 12 ++++++++++++ cparser/pre_parser.mly | 1 + cparser/tests/generated/Makefile | 12 ++++++++++++ 8 files changed, 94 insertions(+) diff --git a/Makefile.menhir b/Makefile.menhir index 82f44e5f..74bd14e2 100644 --- a/Makefile.menhir +++ b/Makefile.menhir @@ -1,3 +1,15 @@ +####################################################################### +# # +# The Compcert verified compiler # +# # +# François Pottier, INRIA Paris-Rocquencourt # +# # +# Copyright Institut National de Recherche en Informatique et en # +# Automatique. All rights reserved. This file is distributed # +# under the terms of the INRIA Non-Commercial License Agreement. # +# # +####################################################################### + # This is a Makefile fragment for Menhir-specific aspects. # Executable. diff --git a/cparser/ErrorReports.ml b/cparser/ErrorReports.ml index 445b8412..a271ece1 100644 --- a/cparser/ErrorReports.ml +++ b/cparser/ErrorReports.ml @@ -1,3 +1,18 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* François Pottier, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright Institut National de Recherche en Informatique et en *) +(* Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU General Public License as published by *) +(* the Free Software Foundation, either version 2 of the License, or *) +(* (at your option) any later version. This file is also distributed *) +(* under the terms of the INRIA Non-Commercial License Agreement. *) +(* *) +(* *********************************************************************) + open Lexing open Pre_parser.MenhirInterpreter module S = MenhirLib.General (* Streams *) diff --git a/cparser/ErrorReports.mli b/cparser/ErrorReports.mli index e4296e69..f803a08b 100644 --- a/cparser/ErrorReports.mli +++ b/cparser/ErrorReports.mli @@ -1,3 +1,18 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* François Pottier, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright Institut National de Recherche en Informatique et en *) +(* Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU General Public License as published by *) +(* the Free Software Foundation, either version 2 of the License, or *) +(* (at your option) any later version. This file is also distributed *) +(* under the terms of the INRIA Non-Commercial License Agreement. *) +(* *) +(* *********************************************************************) + (* This module is in charge of reporting a syntax error after the pre_parser has failed. *) diff --git a/cparser/GNUmakefile b/cparser/GNUmakefile index d08ef178..c2792301 100644 --- a/cparser/GNUmakefile +++ b/cparser/GNUmakefile @@ -1,3 +1,15 @@ +####################################################################### +# # +# The Compcert verified compiler # +# # +# François Pottier, INRIA Paris-Rocquencourt # +# # +# Copyright Institut National de Recherche en Informatique et en # +# Automatique. All rights reserved. This file is distributed # +# under the terms of the INRIA Non-Commercial License Agreement. # +# # +####################################################################### + # This is a development Makefile. # It is meant to be used by developers who wish to modify the pre_parser. diff --git a/cparser/deLexer.ml b/cparser/deLexer.ml index 7ecfca0c..00308e4b 100644 --- a/cparser/deLexer.ml +++ b/cparser/deLexer.ml @@ -1,3 +1,18 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* François Pottier, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright Institut National de Recherche en Informatique et en *) +(* Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU General Public License as published by *) +(* the Free Software Foundation, either version 2 of the License, or *) +(* (at your option) any later version. This file is also distributed *) +(* under the terms of the INRIA Non-Commercial License Agreement. *) +(* *) +(* *********************************************************************) + (* [delex] converts a terminal symbol (represented as a symbolic string) to a concrete string, which the lexer would accept. *) diff --git a/cparser/handcrafted.messages b/cparser/handcrafted.messages index 1d78360a..ba2031d7 100644 --- a/cparser/handcrafted.messages +++ b/cparser/handcrafted.messages @@ -1,3 +1,15 @@ +####################################################################### +# # +# The Compcert verified compiler # +# # +# François Pottier, INRIA Paris-Rocquencourt # +# # +# Copyright Institut National de Recherche en Informatique et en # +# Automatique. All rights reserved. This file is distributed # +# under the terms of the INRIA Non-Commercial License Agreement. # +# # +####################################################################### + # This file contains a complete list of sentences that cause the pre_parser to # detect an error. diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly index 1de726be..25e7a745 100644 --- a/cparser/pre_parser.mly +++ b/cparser/pre_parser.mly @@ -3,6 +3,7 @@ /* The Compcert verified compiler */ /* */ /* Jacques-Henri Jourdan, INRIA Paris-Rocquencourt */ +/* François Pottier, INRIA Paris-Rocquencourt */ /* */ /* Copyright Institut National de Recherche en Informatique et en */ /* Automatique. All rights reserved. This file is distributed */ diff --git a/cparser/tests/generated/Makefile b/cparser/tests/generated/Makefile index 12a65e11..fb6e7610 100644 --- a/cparser/tests/generated/Makefile +++ b/cparser/tests/generated/Makefile @@ -1,3 +1,15 @@ +####################################################################### +# # +# The Compcert verified compiler # +# # +# François Pottier, INRIA Paris-Rocquencourt # +# # +# Copyright Institut National de Recherche en Informatique et en # +# Automatique. All rights reserved. This file is distributed # +# under the terms of the INRIA Non-Commercial License Agreement. # +# # +####################################################################### + .PHONY: all clean SOURCES := $(wildcard *.c) -- cgit From c46723c0169145d41d1879c236f53314456f1ba1 Mon Sep 17 00:00:00 2001 From: François Pottier Date: Fri, 23 Oct 2015 14:03:45 +0200 Subject: Updated [configure] to require today's Menhir. --- configure | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure b/configure index a04fd2f5..eb9c2e7b 100755 --- a/configure +++ b/configure @@ -281,20 +281,21 @@ else ocaml_opt_comp=false fi +MENHIR_REQUIRED=20151023 echo "Testing Menhir... " | tr -d '\n' menhir_ver=`menhir --version 2>/dev/null | sed -n -e 's/^.*version \([0-9]*\).*$/\1/p'` case "$menhir_ver" in 20[0-9][0-9][0-9][0-9][0-9][0-9]) - if test "$menhir_ver" -ge 20140422; then + if test "$menhir_ver" -ge $MENHIR_REQUIRED; then echo "version $menhir_ver -- good!" else echo "version $menhir_ver -- UNSUPPORTED" - echo "Error: CompCert requires Menhir version 20140422 or later." + echo "Error: CompCert requires Menhir version $MENHIR_REQUIRED or later." missingtools=true fi;; *) echo "NOT FOUND" - echo "Error: make sure Menhir version 20140422 or later is installed." + echo "Error: make sure Menhir version $MENHIR_REQUIRED or later is installed." missingtools=true;; esac -- cgit