It seems that match operators (=~ and !~) aren''t currently implemented. e.g. '''' =~ // crashes while parsing. Where should one look to implement this? -- Seo Sanghyeon
On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com> wrote:> It seems that match operators (=~ and !~) aren''t currently > implemented. e.g. '''' =~ // crashes while parsing. > > Where should one look to implement this? >It''s in RegexpOps.cs. There''s actually an interesting design issue around Regexp. On one hand, it would be really nice if we could somehow use System.Text.RegularExpressions to implement Ruby''s Regexp. On the other hand, there might be too much of an impedance mismatch between the two. I haven''t compared them yet... I wonder how different they are? - John
2007/10/15, John Messerly <jomes at microsoft.com>:> On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com> wrote: > > It seems that match operators (=~ and !~) aren''t currently > > implemented. e.g. '''' =~ // crashes while parsing. > > > > Where should one look to implement this? > > It''s in RegexpOps.cs.No, it isn''t. I''m not talking about missing methods, I''m talking about *parsing*. -- Seo Sanghyeon
On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com> wrote:> > 2007/10/15, John Messerly <jomes at microsoft.com>: > > On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com> wrote: > > > It seems that match operators (=~ and !~) aren''t currently > > > implemented. e.g. '''' =~ // crashes while parsing. > > > > > > Where should one look to implement this? > > > > It''s in RegexpOps.cs. > > No, it isn''t. I''m not talking about missing methods, I''m talking about > *parsing*.I don''t see any evidence in src\IronRuby\Compiler\Parser\Parser.y that these symbol combinations are recognized as distinct tokens. -- Curt Hagenlocher curt at hagenlocher.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071014/3b8633e4/attachment.html
2007/10/15, Curt Hagenlocher <curt at hagenlocher.org>:> I don''t see any evidence in > src\IronRuby\Compiler\Parser\Parser.y that these symbol > combinations are recognized as distinct tokens.But the stacktrace shows Ruby.Compiler.Parser.Parse, so I assumed it''s crashing while parsing. Am I wrong? $ cat t.rb '''' =~ // $ mono rbx.exe t.rb System.NullReferenceException: Object reference not set to an instance of an object at Ruby.Compiler.Ast.ExpressionStatement..ctor (Ruby.Compiler.Ast.Expression expression) [0x00000] at Ruby.Compiler.Parser.DoAction (Int32 action) [0x00000] at Ruby.Compiler.ShiftReduceParser`2[Ruby.Compiler.TokenValue,Microsoft.Scripting.SourceSpan].Reduce (Int32 ) [0x00000] at Ruby.Compiler.ShiftReduceParser`2[Ruby.Compiler.TokenValue,Microsoft.Scripting.SourceSpan].Parse () [0x00000] at Ruby.Compiler.Parser.Parse (Microsoft.Scripting.CompilerContext cc) [0x00000] at Ruby.Runtime.RubyContext.ParseSourceCode (Microsoft.Scripting.CompilerContext context) [0x00000] at Microsoft.Scripting.LanguageContext.CompileSourceCode (Microsoft.Scripting.Hosting.SourceUnit sourceUnit, Microsoft.Scripting.CompilerOptions options, Microsoft.Scripting.Hosting.ErrorSink errorSink) [0x00000] at Microsoft.Scripting.ScriptDomainManager.CompileModule (System.String name, ScriptModuleKind kind, Microsoft.Scripting.Scope scope, Microsoft.Scripting.CompilerOptions options, Microsoft.Scripting.Hosting.ErrorSink errorSink, Microsoft.Scripting.Hosting.SourceUnit[] sourceUnits) [0x00000] at Microsoft.Scripting.ScriptDomainManager.CompileModule (System.String name, Microsoft.Scripting.Hosting.SourceUnit sourceUnit) [0x00000] at Ruby.Hosting.RubyCommandLine.RunFile (System.String path) [0x00000] -- Seo Sanghyeon
On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com> wrote:> > 2007/10/15, Curt Hagenlocher <curt at hagenlocher.org>: > > I don''t see any evidence in > > src\IronRuby\Compiler\Parser\Parser.y that these symbol > > combinations are recognized as distinct tokens. > > But the stacktrace shows Ruby.Compiler.Parser.Parse, so I assumed it''s > crashing while parsing. Am I wrong?Hmm.. I had assumed that the parser was recognizing this as <value><equals><binary negation><value>. I was wrong, and these symbols are actually defined as MATCH and NMATCH in the grammar. Their implementation, however, is commented out: | arg MATCH arg { //$$ = new MatchExpression($1, $3, @$); } | arg NMATCH arg { //$$ = new NotExpression(new MatchExpression($1, $3, @$), @$); } There does not actually appear to be any implementation of the MatchExpression class. -- Curt Hagenlocher curt at hagenlocher.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071014/021b37a1/attachment.html
We don''t support regular expressions yet. Coming soon. Please, be patient. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Curt Hagenlocher Sent: Sunday, October 14, 2007 4:29 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Match operator On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com<mailto:sanxiyn at gmail.com>> wrote: 2007/10/15, Curt Hagenlocher <curt at hagenlocher.org<mailto:curt at hagenlocher.org>>:> I don''t see any evidence in > src\IronRuby\Compiler\Parser\Parser.y that these symbol > combinations are recognized as distinct tokens.But the stacktrace shows Ruby.Compiler.Parser.Parse, so I assumed it''s crashing while parsing. Am I wrong? Hmm.. I had assumed that the parser was recognizing this as <value><equals><binary negation><value>. I was wrong, and these symbols are actually defined as MATCH and NMATCH in the grammar. Their implementation, however, is commented out: | arg MATCH arg { //$$ = new MatchExpression($1, $3, @$); } | arg NMATCH arg { //$$ = new NotExpression(new MatchExpression($1, $3, @$), @$); } There does not actually appear to be any implementation of the MatchExpression class. -- Curt Hagenlocher curt at hagenlocher.org<mailto:curt at hagenlocher.org> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071015/d5bea2f1/attachment.html
Hi Tomas, I took a stab at seeing if I could get something working with that. But I couldn''t seem to get things to get recognized. The steps I took were: Add a new MatchExpression class which derives from Expression in Ruby\Compiler\AST\Expressions. Define a constructor which takes three parameters, and have it call the base constructor passing in location. Override TransformRead in my MatchExpression class. I then modified Parser.y to uncomment out the line listed below. I tried a pass and it didn''t call it, so I tried running the ClassInitGenerator, but it didn''t seem to change anything. On a whim, I modified Parser.Generated.cs where that line from Parser.y was, and had it call yyval.Expression = new MatchExpresssion. This worked (i.e.it called my method), but then I got that the method wasn''t implemented. So I tried adding a method to MutableStringOps for Match, but it didn''t seem to find it. I''m really trying to understand how one goes from end-to-end here, so can anyone offer some insights? Cory From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek Sent: Monday, October 15, 2007 12:02 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Match operator We don''t support regular expressions yet. Coming soon. Please, be patient. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Curt Hagenlocher Sent: Sunday, October 14, 2007 4:29 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Match operator On 10/14/07, Sanghyeon Seo <sanxiyn at gmail.com<mailto:sanxiyn at gmail.com>> wrote: 2007/10/15, Curt Hagenlocher <curt at hagenlocher.org<mailto:curt at hagenlocher.org>>:> I don''t see any evidence in > src\IronRuby\Compiler\Parser\Parser.y that these symbol > combinations are recognized as distinct tokens.But the stacktrace shows Ruby.Compiler.Parser.Parse, so I assumed it''s crashing while parsing. Am I wrong? Hmm.. I had assumed that the parser was recognizing this as <value><equals><binary negation><value>. I was wrong, and these symbols are actually defined as MATCH and NMATCH in the grammar. Their implementation, however, is commented out: | arg MATCH arg { //$$ = new MatchExpression($1, $3, @$); } | arg NMATCH arg { //$$ = new NotExpression(new MatchExpression($1, $3, @$), @$); } There does not actually appear to be any implementation of the MatchExpression class. -- Curt Hagenlocher curt at hagenlocher.org<mailto:curt at hagenlocher.org> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071015/cb025d51/attachment-0001.html
Tomas Matousek:> > We don''t support regular expressions yet. Coming soon. Please, be > patient.I would say that we *barely* support regex today. There is a transformation implemented to allow regexp = /some .net regex expression/ Curt Hagenlocher:> > Hmm.. I had assumed that the parser was recognizing this as > <value><equals><binary negation><value>. I was wrong, and these > symbols are actually defined as MATCH and NMATCH in the grammar. > Their implementation, however, is commented out: > > | arg MATCH arg > { > //$$ = new MatchExpression($1, $3, @$); } > | arg NMATCH arg > { > //$$ = new NotExpression(new MatchExpression($1, $3, @$), @$); } > > There does not actually appear to be any implementation of the > MatchExpression class.This is where you would need to look to start work on implementing (at the very least) a .NET implementation of regex. Another thing that you could consider doing is defining a regex .NET interface so that we can swap out the interim .NET regex implementation for a Ruby-compatible regex implementation down the road. Thanks, -John