It seems that match operators (=~ and !~) aren’t currently
implemented. e.g. ‘’ =~ // crashes while parsing.
Where should one look to implement this?
It seems that match operators (=~ and !~) aren’t currently
implemented. e.g. ‘’ =~ // crashes while parsing.
Where should one look to implement this?
On 10/14/07, Sanghyeon S. [email protected] 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?
2007/10/15, John M. [email protected]:
On 10/14/07, Sanghyeon S. [email protected] 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.
2007/10/15, Curt H. [email protected]:
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.ShiftReduceParser2[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]
On 10/14/07, Sanghyeon S. [email protected] wrote:
2007/10/15, Curt H. [email protected]:
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
. 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.
On 10/14/07, Sanghyeon S. [email protected] wrote:
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.
We don’t support regular expressions yet. Coming soon. Please, be
patient.
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Curt
Hagenlocher
Sent: Sunday, October 14, 2007 4:29 PM
To: [email protected]
Subject: Re: [Ironruby-core] Match operator
On 10/14/07, Sanghyeon S. <[email protected]mailto:[email protected]>
wrote:
2007/10/15, Curt H.
<[email protected]mailto:[email protected]>:
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
. 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.
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: [email protected]
[mailto:[email protected]] On Behalf Of Tomas M.
Sent: Monday, October 15, 2007 12:02 PM
To: [email protected]
Subject: Re: [Ironruby-core] Match operator
We don’t support regular expressions yet. Coming soon. Please, be
patient.
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Curt
Hagenlocher
Sent: Sunday, October 14, 2007 4:29 PM
To: [email protected]
Subject: Re: [Ironruby-core] Match operator
On 10/14/07, Sanghyeon S. <[email protected]mailto:[email protected]>
wrote:
2007/10/15, Curt H.
<[email protected]mailto:[email protected]>:
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
. 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.
Tomas M.:
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 H.:
{
//$$ = 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs