From 5111ae23296109aab9d6088586825f94f48d20ea Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:44:49 +0900 Subject: [PATCH] Do not use semicolon --- spec/lrama/lexer_spec.rb | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/spec/lrama/lexer_spec.rb b/spec/lrama/lexer_spec.rb index 19c4621d..2e06fe65 100644 --- a/spec/lrama/lexer_spec.rb +++ b/spec/lrama/lexer_spec.rb @@ -13,7 +13,8 @@ expect(lexer.next_token).to eq([:STRING, '"3.0"']) expect(lexer.next_token).to eq(['%{', '%{']) - lexer.status = :c_declaration; lexer.end_symbol = '%}' + lexer.status = :c_declaration + lexer.end_symbol = '%}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: "\n// Prologue\n")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 7, first_column: 2, last_line: 9, last_column: 0) @@ -30,7 +31,8 @@ expect(lexer.next_token).to eq(['%printer', '%printer']) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: "\n print_int();\n")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 15, first_column: 10, last_line: 17, last_column: 0) @@ -41,7 +43,8 @@ expect(lexer.next_token).to eq(['%printer', '%printer']) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: "\n print_token();\n")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 18, first_column: 10, last_line: 20, last_column: 0) @@ -53,7 +56,8 @@ expect(lexer.next_token).to eq(['%lex-param', '%lex-param']) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: 'struct lex_params *p')]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 22, first_column: 12, last_line: 22, last_column: 32) @@ -63,7 +67,8 @@ expect(lexer.next_token).to eq(['%parse-param', '%parse-param']) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: 'struct parse_params *p')]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 23, first_column: 14, last_line: 23, last_column: 36) @@ -73,7 +78,8 @@ expect(lexer.next_token).to eq(['%initial-action', '%initial-action']) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: "\n initial_action_func(@$);\n")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 26, first_column: 1, last_line: 28, last_column: 0) @@ -84,7 +90,8 @@ expect(lexer.next_token).to eq(['%union', '%union']) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: "\n int i;\n long l;\n char *str;\n")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 30, first_column: 8, last_line: 34, last_column: 0) @@ -162,7 +169,8 @@ expect(lexer.next_token).to eq([:IDENTIFIER, token_class::Ident.new(s_value: 'tPLUS')]) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: " code 1 ")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 63, first_column: 11, last_line: 63, last_column: 19) @@ -173,7 +181,8 @@ expect(lexer.next_token).to eq([:IDENTIFIER, token_class::Ident.new(s_value: 'keyword_class')]) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: " code 2 ")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 64, first_column: 23, last_line: 64, last_column: 31) @@ -185,7 +194,8 @@ expect(lexer.next_token).to eq([:IDENTIFIER, token_class::Ident.new(s_value: 'keyword_end')]) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: " code 3 ")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 64, first_column: 58, last_line: 64, last_column: 66) @@ -198,7 +208,8 @@ expect(lexer.next_token).to eq([:IDENTIFIER, token_class::Ident.new(s_value: 'keyword_class')]) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: " code 4 ")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 65, first_column: 23, last_line: 65, last_column: 31) @@ -210,7 +221,8 @@ expect(lexer.next_token).to eq([:IDENTIFIER, token_class::Ident.new(s_value: 'keyword_end')]) expect(lexer.next_token).to eq(['{', '{']) - lexer.status = :c_declaration; lexer.end_symbol = '}' + lexer.status = :c_declaration + lexer.end_symbol = '}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: " code 5 ")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 65, first_column: 58, last_line: 65, last_column: 66) @@ -259,7 +271,8 @@ expect(lexer.next_token).to eq([:STRING, '"3.0"']) expect(lexer.next_token).to eq(['%{', '%{']) - lexer.status = :c_declaration; lexer.end_symbol = '%}' + lexer.status = :c_declaration + lexer.end_symbol = '%}' token = lexer.next_token expect(token).to eq([:C_DECLARATION, token_class::UserCode.new(s_value: "\n// Prologue\n")]) expect(token[1].location).to eq Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 7, first_column: 2, last_line: 9, last_column: 0) @@ -323,7 +336,8 @@ it do grammar_file = Lrama::Lexer::GrammarFile.new("invalid.y", "@invalid") lexer = Lrama::Lexer.new(grammar_file) - lexer.status = :c_declaration; lexer.end_symbol = "%}" + lexer.status = :c_declaration + lexer.end_symbol = "%}" expect { lexer.next_token }.to raise_error(ParseError, "Unexpected code: @invalid.") end