Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

53 regexp#54

Merged
skx merged 16 commits intomasterfrom
53-regexp
Nov 11, 2019
Merged

53 regexp#54
skx merged 16 commits intomasterfrom
53-regexp

Conversation

@skx
Copy link
Copy Markdown
Owner

@skx skx commented Nov 9, 2019

This pull request will close #53, by implementing support for regular expressions as objects.

Currently the following program works:

frodo ~/Repos/github.com/skx/monkey $ cat reg.mon
x = /steve/i;

puts( x, " is type:" , type(x), "\n" );

It produces:

frodo ~/Repos/github.com/skx/monkey $ go build . ; ./monkey reg.mon 
(?i)steve is type:regexp

Note here the flag /i has been converted to the version go prefers, the (?i) prefix.

Outstanding task is mostly to implement !~ and =~ operators.

@skx skx self-assigned this Nov 9, 2019
@skx
Copy link
Copy Markdown
Owner Author

skx commented Nov 9, 2019

Sample code works:

if ( "Steve" ~= /steve/i ) {
   puts("This is fine!\n");
}
if ( "sSteve" !~ /^steve/i ) {
   puts("Thisf is fine!\n");
}

Probably needs more love, but a good work in progress.

@skx
Copy link
Copy Markdown
Owner Author

skx commented Nov 11, 2019

Current state:

  • match operators !~ + ~= both do type-chcking on the right hand side.
  • two flags supported /m & /i . Mixtures are fine /mi /im.
  • seems to work.

@skx skx merged commit 8a94704 into master Nov 11, 2019
@skx skx deleted the 53-regexp branch November 12, 2019 14:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add regular expression support

1 participant