Skip to content

#4 Improved expression parsing with names - #6

Merged
pombredanne merged 15 commits into
masterfrom
4-improved-expression-parsing-with-names
Feb 10, 2017
Merged

#4 Improved expression parsing with names#6
pombredanne merged 15 commits into
masterfrom
4-improved-expression-parsing-with-names

Conversation

@pombredanne

Copy link
Copy Markdown
Member

This is a a brand new parser using a pure-python Aho-Corasick-based lexical scanner that brings a great flexibility to validate arbitrary expressions including weird things like GPL-20 or later with classpath exception and mit (the one with sublicense) where each of GPL-20 or later , classpath exception and mit (the one with sublicense) are resolved to proper license symbols (and eventually identifiers).

This is made possible by the great library at https://github.com/WojciechMula/pyahocorasick by @WojciechMula . It uses only the simple Python implementation as expressions are small and there is no need for speed here. It has been modified significantly to return also non-matching substrings and demux overlapping results.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
 * remove unsued __len__ function
 * fix issue for trailing unknown strings

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
 * now fully supporting WITH expressions (including when mixed with
   weird OR or when a "with" word  is part of a license alias).
 * support arbitrary possibly ambiguous expressions using
   a new Aho-Corasick-based lexical scanner populated with known
   symbols that resolves known license names, keys or aliases at
   tokenizing time
 * add new render() function to render symbols.
 * add new tests, moved several doc tests to proper tests.
 * drop LicenseRef in favor of plain symbols
 * improve error and validation handling

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
 * a list of plain strings can now be used as a symbols list.
 * also relaxed unicode requirements for Python 2 as long as a
   string can convert to unicode without error
 * refine the render support
 * implement correct handling of "license_symbols" function
   and keys with optional unique arg and optional decompose arg
   to decompose "A with B" in A and B optionally. 

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
@pombredanne

Copy link
Copy Markdown
Member Author

@sschuberth you had a good hunch about the travis issue: the python 3 tests were running only on Appveyor. So I hope I fixed the setup for Travis.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
@pombredanne

Copy link
Copy Markdown
Member Author

Hum.... The Python 3 tests still do not run, only 2.7 ... on Travis :| I know they pass otherwise so I will likely ignore

@pombredanne

Copy link
Copy Markdown
Member Author

I am merging and I entered #8 to fix Travis later.

@pombredanne
pombredanne merged commit 126164c into master Feb 10, 2017
@pombredanne
pombredanne deleted the 4-improved-expression-parsing-with-names branch February 15, 2017 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant