morning all,
I agree with David that an (additional) explicit grammar is not strictly
necessary -- the well-formedness conditions are implicit in the code, and
the regexes that govern e.g. slice parsing are themselves a species of
grammar (perl regexes are basically Chomsky type-3 grammars on steroids).
Also, an explicit BNF-style grammar would only make the syntax explicit,
not the semantics: it wouldn't in and of itself tell us anything about what
the constituents (terminals and non-terminals) *mean*. That said, an
explicit grammar with an intuitive naming scheme for the constituents tends
to go a long way as far as documentation is concerned, even without
explicit (formal) semantics, which tend to get technical and messy (just
like code does), and can also help to make gaps, omissions, and potential
extensions of the existing syntax more apparent. All in all, I think that
if there's a transparent and self-documenting way to bootstrap and maintain
an explicit grammar (such as Parse::Yapp for context-free LALR parsers),
that can only be a Good Thing. Of course, as a computational linguist, my
opinions on the matter of grammars may be somewhat biased ;-)
marmosets,
Bryan
Post by David MertensWhat needs to be grammarized? All PDL operations in Perl code already fit
within the grammar provided Perl for object methods and functions.
PDL::NiceSlice does not have an explicit grammar, but one could probably be
written. I don't think we'd win much speed over the regex-based
implementation unless we did some sort of keyword-like modification to the
Perl lexer/tokenizer, but that's not really possible with Perl in its
current state.
However, if you are proposing something like modifying Perl's
lexer/tokenizer to make a formal grammar for PDL::NiceSlice, I can think of
some other notation that might be nice to have. Matlab has the "Matrix \
vector" for matrix-inversion-times-vector that I think is nice.
What's left? PDL::PP? That needs more than a grammar... :-)
David
Post by Chris MarshallI've been thinking about ways to improve and future-proof PDL and how
to smooth the PDL-2.x to PDL3 transistion. Does it make sense to
consider developing explicit BNF grammars for various PDL features as
a way to better specify (and quantify!) what PDL "means"? E.g., if we
specify a grammar for NiceSlice syntax, that might make is easier to
make a more portable implementation, say using Marpa...
Thoughts (I'm not a computer scientist)?
Chris
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." -- Brian Kernighan
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
--
Bryan Jurish "There is *always* one more bug."
***@gmail.com -Lubarsky's Law of Cybernetic Entomology