evoldoers / biomake

GNU-Make-like utility for managing builds and complex workflows
BSD 3-Clause "New" or "Revised" License
103 stars 9 forks source link

Regex dependency #66

Closed ihh closed 6 years ago

ihh commented 6 years ago

Allows matching of Perl-style regexes in Prolog blocks, via https://github.com/mndrix/regex

test_$(ABC): { =~(ABC,'^a') }
    echo Fired rule for $@ >$@

This will fire for test_apple but not test_cat or test_APPLE.

Introduces external dependency on https://github.com/mndrix/regex

cmungall commented 6 years ago

This is a showstopper: https://github.com/mndrix/regex/issues/7

We can use http://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/pcre.html%27) as suggested in the ticket. This is now bundled by default in the stable 7.6.x series. Some users may need to upgrade their swi-prolog installation.

cmungall commented 6 years ago

I'm being dense, I can't figure out how the regex test passes, if ^ doesn't work.. it looks like your PR introduces the dependency but doesn't actually extend the grammar, so the test passes by an accident of mis-parsing...?

ihh commented 6 years ago

The test passes because, I think, the prefix notation =~(TEXT,REGEX) works but the infix notation TEXT =~ REGEX doesn't, or maybe it's something about quoting the REGEX when it begins with a caret... not sure... anyway it's moot because I actually wanted to go with pcre (I tried it first and failed), I should have checked with a more recent build. I've now amended the PR to use pcre, see what you think.

cmungall commented 6 years ago

Looks great

And doh, I was scanning the gnumake_parser code for =~, but I forgot that the mndrix lib used infix and that {...} executed prolog, all makes sense now

ihh commented 6 years ago

btw the modifications to queue.pl have nothing to do with the regex extension, they're about implementing the $(SHELL) variable (see #54), I rolled them into this branch by accident...

ihh commented 6 years ago

for the record, the syntax is now (in line with PCRE)

test_$(ABC): { re_match(ABC,'^a') }
    echo Fired rule for $@ >$@

Goodbye to the =~ operator...