From: George Ogata Date: 2006-12-01T21:44:46+09:00 Subject: Re: BUG: ruby-mode.el : '/=' operator breaks following indentation On 11/30/06, Jeremy Henty wrote: > Thanks, that works. A slightly better fix is to add a ';' as well to > convince the major mode that the statement has ended, otherwise it > adds extra indentation to the next line. > > def foo > x /= y # / ; > bar > end Hmm, my ruby-mode doesn't seem to need the ';'. I'm using the CVS HEAD version with XEmacs 21.4.19. > I wonder how the Ruby parser decides that /= is an operator and not > the start of a regexp? It's just the way the grammar is defined. For it to be a regexp, you'd need parens on the call to #x. g@crash:~$ cat test.rb x /=/ g@crash:~$ ruby test.rb test.rb:1: unterminated string meets end of file test.rb:1: parse error, unexpected tSTRING_END, expecting tSTRING_CONTENT or tREGEXP_END or tSTRING_DBEG or tSTRING_DVAR g@crash:~$ cat test2.rb x(/=/) g@crash:~$ ruby test2.rb test2.rb:1: undefined method `x' for main:Object (NoMethodError) g@crash:~$ ruby -v ruby 1.8.4 (2005-12-24) [i686-linux] The ruby-mode parser is much simpler than the one the ruby interpreter uses. For a start, it's not based on a proper grammar. I don't suppose someone's tried to use semantic [1] or something to produce something a little more robust? [1] http://www.xemacs.org/Documentation/packages/html/semantic.html