Skip to content
This repository has been archived by the owner on May 3, 2018. It is now read-only.

Initial work on a regex implementation. #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Initial work on a regex implementation. #13

wants to merge 1 commit into from

Conversation

deontologician
Copy link
Contributor

This is a work in progress attempting to implement issue #12

Currently, I have it passing 172 tests, with 182 failing. It involves a bit of hackery because the tests don't have quite what's needed to test a regex implementation. URI Templates also aren't quite bijective with some ambiguous cases like:

'{varA,varB,varC}'

If we get a string like 'a,b,c' we have the following possible ways to match against the uritemplate:

varA, varB, varC = 'a,b,c', None, None
varA, varB, varC = 'a,b', 'c', None
varA, varB, varC = 'a', 'b', 'c'
varA, varB, varC = None, 'a,b,c', None
varA, varB, varC = None, 'a,b', 'c'
varA, varB, varC = None, 'a', 'b,c'
varA, varB, varC = None, None, 'a,b,c'

Some of these are more reasonable answers than others, but the fact remains that if you feed these into the expand function, they'll result in the same output. So some sort of rule has to be made to disambiguate in these cases if a regex matcher is going to be complete.

@graingert
Copy link
Contributor

I don't think it's possible to do a regex matcher and parser. I'm only really looking for a library that can define the smallest language that defines at least the language defined by any URI template.

@graingert
Copy link
Contributor

+1 for this though

outstring, var=var, match_var=match_var, answers=answers)


if __name__ == "__main__":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a strange way to run the tests? Does the project not have a test runner?

@deontologician
Copy link
Contributor Author

@graingert The test runner is custom because it's picking up the json files used for the main tests on this package, it just uses them in a different way.

@graingert
Copy link
Contributor

This project should really switch to nose or py.test.
On 22 Apr 2014 01:11, "Josh Kuhn" [email protected] wrote:

@graingert https://github.com/graingert The test runner is custom
because it's picking up the json files used for the main tests on this
package, it just uses them in a different way.

Reply to this email directly or view it on GitHubhttps://github.com//pull/13#issuecomment-40991104
.

@deontologician
Copy link
Contributor Author

I guess the benefit for this project is that it's implementing a standard, and the tests for the standard are just JSON, so multiple language implementations can use the same exact tests.

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.

2 participants