Amethyst is generalization of ometa PEG parser and tool for generic
pattern matching.
Amethyst tries to be better alternative to regular expressions. Example
follows:
x=y=nil
(| int:x “+” int:y |).match(“2+2”)
puts x+y # → 4
pattern = (| ‘a’| ‘b’ |)
puts puts pattern.match(“b”) #-> b
puts puts pattern.match(“abc”) #-> FAIL
puts Amethyst.find(“abc”,pattern) #->“a”
For describing more complex grammars see how parser of amethyst is done.
http://kam.mff.cuni.cz/~ondra/amethyst/parser.ame.html
And how is syntax highligthing of above done.
http://kam.mff.cuni.cz/~ondra/amethyst/parser_highlight.ame.html
We allow pattern matching of arbitrary ruby objects. A example of
semigeneric traverser is following
http://kam.mff.cuni.cz/~ondra/amethyst/traverser.ame.html
A source can be found at
comments are welcome.
–
Fatal error right in front of screen