Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit too long text when printing module Lrama::Lexer::GrammarFile class #393

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

ydah
Copy link
Collaborator

@ydah ydah commented Apr 6, 2024

It would be great if it could be shortened because it would be very difficult to see when debugging.

before:

#<Lrama::Lexer::Token::Ident:0x0000000104fd0fc0
 @alias_name=nil,
 @location=
  #<Lrama::Lexer::Location:0x000000010516e5d0
   @first_column=0,
   @first_line=27,
   @grammar_file=
    #<Lrama::Lexer::GrammarFile:0x0000000104e975a0
     @path="spec/fixtures/inlining/resolve_index.y",
     @text=
      "/*\n" +
      " * This is comment for this file.\n" +
      " */\n" +
      "\n" +
      "%{\n" +
      "// Prologue\n" +
      "static int yylex(YYSTYPE *val, YYLTYPE *loc);\n" +
      "static int yyerror(YYLTYPE *loc, const char *str);\n" +
      "%}\n" +
      "\n" +
      "%union {\n" +
      "    int i;\n" +
      "}\n" +
      "\n" +
      "%token <i> NUM\n" +
      "%type <i> expression\n" +
      "\n" +
      "%rule %inline op  : '+' '=' { += }\n" +
      "                  | '-' '-' '=' { -= }\n" +
      "                  ;\n" +
      "\n" +
      "%rule %inline other_op : '*' '=' { *= }\n" +
      "                       ;\n" +
      "\n" +
      "%%\n" +
      "\n" +
      "expression      : NUM\n" +
      "                | expression op expression other_op { $$ = $1 $2 $3 $4; }\n" +
      "                ;\n" +
      "\n" +
      "\n" +
      "\n" +
      "%%\n" +
      "\n" +
      "static int yylex(YYSTYPE *yylval, YYLTYPE *loc)\n" +
      "{\n" +
      "  return 0;\n" +
      "}\n" +
      "\n" +
      "static int yyerror(YYLTYPE *loc, const char *str)\n" +
      "{\n" +
      "  return 0;\n" +
      "}\n" +
      "\n" +
      "int main(int argc, char *argv[])\n" +
      "{\n" +
      "}\n">,
   @last_column=10,
   @last_line=27>,
 @s_value="expression">

after:

#<Lrama::Lexer::Token::Ident:0x0000000100f6c4c0 @alias_name=nil, @location=#<Lrama::Lexer::Location:0x0000000100faf518 @first_column=0, @first_line=27, @grammar_file=<Lrama::Lexer::GrammarFile: @path=spec/fixtures/inlining/resolve_index.y, @text="/*\n * This is comment for this file.\n */\n\n%{\n// ...">, @last_column=10, @last_line=27>, @s_value="expression">

…lass

before:
```
#<Lrama::Lexer::Token::Ident:0x0000000104fd0fc0
 @alias_name=nil,
 @location=
  #<Lrama::Lexer::Location:0x000000010516e5d0
   @first_column=0,
   @first_line=27,
   @grammar_file=
    #<Lrama::Lexer::GrammarFile:0x0000000104e975a0
     @path="spec/fixtures/inlining/resolve_index.y",
     @text=
      "/*\n" +
      " * This is comment for this file.\n" +
      " */\n" +
      "\n" +
      "%{\n" +
      "// Prologue\n" +
      "static int yylex(YYSTYPE *val, YYLTYPE *loc);\n" +
      "static int yyerror(YYLTYPE *loc, const char *str);\n" +
      "%}\n" +
      "\n" +
      "%union {\n" +
      "    int i;\n" +
      "}\n" +
      "\n" +
      "%token <i> NUM\n" +
      "%type <i> expression\n" +
      "\n" +
      "%rule %inline op  : '+' '=' { += }\n" +
      "                  | '-' '-' '=' { -= }\n" +
      "                  ;\n" +
      "\n" +
      "%rule %inline other_op : '*' '=' { *= }\n" +
      "                       ;\n" +
      "\n" +
      "%%\n" +
      "\n" +
      "expression      : NUM\n" +
      "                | expression op expression other_op { $$ = $1 $2 $3 $4; }\n" +
      "                ;\n" +
      "\n" +
      "\n" +
      "\n" +
      "%%\n" +
      "\n" +
      "static int yylex(YYSTYPE *yylval, YYLTYPE *loc)\n" +
      "{\n" +
      "  return 0;\n" +
      "}\n" +
      "\n" +
      "static int yyerror(YYLTYPE *loc, const char *str)\n" +
      "{\n" +
      "  return 0;\n" +
      "}\n" +
      "\n" +
      "int main(int argc, char *argv[])\n" +
      "{\n" +
      "}\n">,
   @last_column=10,
   @last_line=27>,
 @s_value="expression">
```

after:
```
#<Lrama::Lexer::Token::Ident:0x0000000100f6c4c0 @alias_name=nil, @location=#<Lrama::Lexer::Location:0x0000000100faf518 @first_column=0, @first_line=27, @grammar_file=<Lrama::Lexer::GrammarFile: @path=spec/fixtures/inlining/resolve_index.y, @text="/*\n * This is comment for this file.\n */\n\n%{\n// ...">, @last_column=10, @last_line=27>, @s_value="expression">
```
@yui-knk yui-knk merged commit 300456a into ruby:master Apr 7, 2024
16 checks passed
@ydah ydah deleted the omit-long-output branch April 7, 2024 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants