From 1fbebe9ae80137334cab0624bbe4ca9c33b37b48 Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Sat, 2 Dec 2023 21:03:18 +0900 Subject: [PATCH 1/2] Organize rbs in grammar --- sig/lrama/grammar/parameterizing_rules/builder.rbs | 5 +++-- sig/lrama/grammar/parameterizing_rules/builder/base.rbs | 4 +++- .../grammar/parameterizing_rules/builder/separated_list.rbs | 2 ++ .../parameterizing_rules/builder/separated_nonempty_list.rbs | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sig/lrama/grammar/parameterizing_rules/builder.rbs b/sig/lrama/grammar/parameterizing_rules/builder.rbs index a2c8ba07..8dcc6f07 100644 --- a/sig/lrama/grammar/parameterizing_rules/builder.rbs +++ b/sig/lrama/grammar/parameterizing_rules/builder.rbs @@ -7,14 +7,15 @@ module Lrama @token: Lexer::Token::Parameterizing @key: Symbol @rule_counter: Counter - @lhs: Lexer::Token + @lhs_tag: untyped @user_code: Lexer::Token::UserCode? @precedence_sym: Lexer::Token? @line: Integer? + @builder: Grammar::ParameterizingRules::Builder::Base def initialize: (Lexer::Token token, Counter rule_counter, untyped lhs_tag, Lexer::Token::UserCode? user_code, Lexer::Token? precedence_sym, Integer? line) -> void def build: () -> Array[Rule] - def build_token: () -> Lrama::Lexer::Token + def build_token: () -> Lexer::Token def create_builder: () -> void def validate_key!: () -> void end diff --git a/sig/lrama/grammar/parameterizing_rules/builder/base.rbs b/sig/lrama/grammar/parameterizing_rules/builder/base.rbs index 466bd0ce..e52a5878 100644 --- a/sig/lrama/grammar/parameterizing_rules/builder/base.rbs +++ b/sig/lrama/grammar/parameterizing_rules/builder/base.rbs @@ -3,6 +3,8 @@ module Lrama class ParameterizingRules class Builder class Base + attr_reader build_token: Lexer::Token::Ident + def initialize: (Lexer::Token::Parameterizing token, Counter rule_counter, untyped lhs_tag, Lexer::Token::UserCode? user_code, Lexer::Token? precedence_sym, Integer? line) -> void def build: () -> Array[Rule] @@ -10,7 +12,7 @@ module Lrama @token: Lexer::Token::Parameterizing @key: Symbol @rule_counter: Counter - @lhs: Lexer::Token + @lhs_tag: untyped @user_code: Lexer::Token::UserCode? @precedence_sym: Lexer::Token? @line: Integer? diff --git a/sig/lrama/grammar/parameterizing_rules/builder/separated_list.rbs b/sig/lrama/grammar/parameterizing_rules/builder/separated_list.rbs index dbdf6629..0f60670d 100644 --- a/sig/lrama/grammar/parameterizing_rules/builder/separated_list.rbs +++ b/sig/lrama/grammar/parameterizing_rules/builder/separated_list.rbs @@ -3,6 +3,8 @@ module Lrama class ParameterizingRules class Builder class SeparatedList < Base + @separator: Lexer::Token + def initialize: (Lexer::Token token, Counter rule_counter, untyped lhs_tag, Lexer::Token::UserCode? user_code, Lexer::Token? precedence_sym, Integer? line) -> void end end diff --git a/sig/lrama/grammar/parameterizing_rules/builder/separated_nonempty_list.rbs b/sig/lrama/grammar/parameterizing_rules/builder/separated_nonempty_list.rbs index 461ce0ab..21cf3322 100644 --- a/sig/lrama/grammar/parameterizing_rules/builder/separated_nonempty_list.rbs +++ b/sig/lrama/grammar/parameterizing_rules/builder/separated_nonempty_list.rbs @@ -3,6 +3,8 @@ module Lrama class ParameterizingRules class Builder class SeparatedNonemptyList < Base + @separator: Lexer::Token + def initialize: (Lexer::Token token, Counter rule_counter, untyped lhs_tag, Lexer::Token::UserCode? user_code, Lexer::Token? precedence_sym, Integer? line) -> void end end From f7724c51f18ab65b2bd1ea4439576db748e8dd02 Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Sat, 2 Dec 2023 21:03:28 +0900 Subject: [PATCH 2/2] Organize rbs in lexer/token --- sig/lrama/lexer/token/parameterizing.rbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sig/lrama/lexer/token/parameterizing.rbs b/sig/lrama/lexer/token/parameterizing.rbs index 351beaf2..92f5d3bb 100644 --- a/sig/lrama/lexer/token/parameterizing.rbs +++ b/sig/lrama/lexer/token/parameterizing.rbs @@ -2,9 +2,9 @@ module Lrama class Lexer class Token class Parameterizing < Token - attr_accessor args: Array[Lrama::Lexer::Token] + attr_accessor args: Array[Lexer::Token] - def initialize: (s_value: String, ?alias_name: String, ?location: Location, ?args: Array[Lrama::Lexer::Token]) -> void + def initialize: (s_value: String, ?alias_name: String, ?location: Location, ?args: Array[Lexer::Token]) -> void def option?: () -> bool def nonempty_list?: () -> bool