develooper Front page | perl.perl6.language | Postings from February 2004

Distributing traits / Rule-matching group properties

Thread Next
From:
Austin Hastings
Date:
February 27, 2004 23:37
Subject:
Distributing traits / Rule-matching group properties
Message ID:
OIEJIIJJCGOEMIJDBHAOAEIJCAAA.Austin_Hastings@Yahoo.com
Another hypothetical:

Suppose you have a browser (which understands "language" traits) or a word processor (which stores "style" and/or "font" information) that is storing some not-text-only string-like things via scalar strings+ or objectrefs.

You want to do something like "search for all occurrences of the word 'From:' in a heading style" or "Find all letters 'l' in french text".

How do you write, and how do you code, the rule(s) for that?

I think it could be a rule junction, as C< /all(<french>, 'l')/ > but that's not entirely satisfying since I don't imagine that rule junctions are going to be the most efficient constructs around. (But would a rulejunction be a valid way of searching?)

Alternatively, there would need to be some way of inquiring about distributed traits. That is, a trait that wasn't actually applied to every single member of a list, but which was "inferred" by some magic accessor. (IOW, the "string" object defines a special version of the trait accessor method (.AUTOTRAIT anyone?) that knows how to query to see if there is a <french>...</french> tagset surrounding this text, or whatever.

With that, you could define a rule called "<french>" and called "</french>" that clevery look like XML but invoke the rules. Something like:

  m« <french>l</french>  »

This has the twin virtues of (1) looking cool; and (2) being really self-explanatory. But, how would you code a rule pair like french and /french?

If that's not doable, is there some other way, especially some variable way, of checking for "traits" at the same time you're matching patterns? (I.e., $language instead of <french>)

=Austin



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About