[Subversion] / PEAK / src / peak / util / fmtparse.py |
No default branch
Bookmark a link to HEAD:
(view)
(download)
(as text)
Removed memoization from 'fmtparse': empirical testing showed that the cache hit rate was incredibly low: only 18 hits in the entire PEAK test suite. Analysis suggests that only grammars having alternatives with similar prefixes are likely to actually receive any benefit from memoization. By contrast, URLs and other simple, structural syntaxes of the kind 'fmtparse' is intended for, almost never require backtracking, and therefore don't really need the memoization. Removing the memoization and related code appears to shave almost a tenth of a second off the test suite's run time.
Change all adapter factories to use only a single argument.
Make 'fmtparse.Repeat()' objects tell their child rules about the separator so that collection features based on primitive types are easier to parse. 'fmtparse' is really in lousy shape and needs to be rewritten/replaced, as it seems to break whenever it's touched. No time in the a3 release cycle for it, though. :( It really needs a rethink, redesign, and rewrite with super-tiny incremental tests instead of "it works or it doesn't" scale tests.
Added 'peak.core' as a minimal subset of 'peak.api'. 'peak.core' offers only "core" API packages and primitives, not the full set of available framework APIs. 'peak.api' will continue to expand as frameworks are added, but 'peak.core' will stay as small as practical. ('peak.exceptions' may in fact end up being removed from 'peak.core', or at least renamed.) Also, added 'peak.util.symbol' module, to contain 'NOT_GIVEN', 'NOT_FOUND', and the 'Symbol' class used to create them.
Minor fix for 'canBeEmpty' support during parsing. If a Conversion parses an empty string, and 'canBeEmpty' is true, and a 'defaultValue' was supplied, the Conversion will now return the default instead of passing the empty string to its converter function.
Enhanced 'fmtparse' and 'peak.model' to allow using types as syntax rules for parsing, including abstract types. An abstract type's syntax is the union (using 'fmtparse.Alternatives') of the syntaxes of its subclasses (as specified by 'mdl_subclassNames').
Removed all uses of deprecated binding APIs.
Fix "inverse refcount leak" introduced when support was added for recursive grammars. Using 'id()' to key a dictionary is a bad idea if the objects you're taking the 'id()' of can be deallocated while the entry is still in the dictionary; this led to occasional weird problems with some grammars. Apparently, when I wrote this I thought there'd be references held for as long as the memo dictionary existed, but this isn't the case. So now, the memo holds a reference to the key object in the value, ensuring that the reference can't go away until the entire dictionary is discarded.
Fix typos reported by Alexander Smishlajev.
By popular demand, added syntax recursion. Added a cheesy and over-simplified test case for recursion. Also, fixed some subtle bugs in Repeat(). 'peak.util.fmtparse' now depends on 'binding.Once', which it technically shouldn't since it lives in 'peak.util'. I'll probably fix this by moving what's now '_once.pyx' to 'peak.util', as it is not specific to the rest of the PEAK framework. But I'll look at that later.
Fix typo found by Oleg Broytmann.
Finished switchover to using protocols.advise() API to declare interfaces.
Misc. doc edits
Integrated syntax-driven processing into 'peak.model', including addition of 'toString' and 'mdl_toString' methods. By defining a 'mdl_syntax' rule in any peak.model.Type subclass, you can get automatic rule-driven conversion to and from strings, including the parsing of nested field contents.
Factored out URL parsing into a more generic parsing framework in 'peak.util.fmtparse', with a few minor optimizations and enhancements.
cvs-admin@eby-sarna.com Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |