4 ms·
The Ruby yacc file is scary to look at. 13+ thousand lines in a single file. Would it be better with hand rolled and they could have abstracted and organized s
by adamgordonbell 5y ago
The Ruby yacc file is scary to look at. 13+ thousand lines in a single file.
Would it be better with hand rolled and they could have abstracted and organized somethings or does it all make sense in its current format if you are familiar with it?
https://github.com/ruby/ruby/blob/v3_0_2/parse.y https://github.com/ruby/ruby/blob/v3_0_2/parse.y
- chrisseaton 5y agoI have a PhD in compiling Ruby and I struggle to read and modify that file.
- adamgordonbell 5y agoRuby is very flexible. Is that the issue? I suspect not, because Scala is super flexible and probably more difficult to parse, but has a better organized parser.
- chrisseaton 5y agoThe language is just quite large and quite complex to parse - context-sensitive and requires interaction back and forth with the lexer as it parses. TreeSitter seems to have a much simpler Ruby parser - but I believe it ignores the context-sensitive parts of Ruby.
- jasonwatkinspdx 5y agoRuby's syntactic flexibility is definitely a big factor in it.