README in citrus-1.6.0 vs README in citrus-1.7.0

- old
+ new

@@ -8,11 +8,11 @@ Citrus is a compact and powerful parsing library for Ruby that combines the elegance and expressiveness of the language with the simplicity and power of parsing expressions. - ** Installation ** += Installation Via RubyGems: $ sudo gem install citrus @@ -22,11 +22,11 @@ $ git clone git://github.com/mjijackson/citrus.git $ cd citrus $ rake package && sudo rake install - ** Background ** += Background In order to be able to use Citrus effectively, you must first understand the difference between syntax and semantics. Syntax is a set of rules that govern the way letters and punctuation may be used in a language. For example, English @@ -97,11 +97,11 @@ These methods can interpret the text of a match using the wealth of information available to them including the text of the match, its position in the input, and any submatches. - ** Syntax ** += Syntax The most straightforward way to compose a Citrus grammar is to use Citrus' own custom grammar syntax. This syntax borrows heavily from Ruby, so it should already be familiar to Ruby programmers. @@ -166,11 +166,11 @@ 'a' 'b' | 'c' # match "a" then "b" (in sequence), or "c" == Super When including a grammar inside another, all rules in the child that have the -same name as a rule in the parent also have access to the super keyword to +same name as a rule in the parent also have access to the "super" keyword to invoke the parent rule. == Labels Match objects may be referred to by a different name than the rule that @@ -179,14 +179,37 @@ chars:/[a-z]+/ # the characters matched by the regular # expression may be referred to as "chars" # in a block method +== Precedence - ** Example ** +The following table contains a list of all operators and their precedence. A +higher level of precedence indicates tighter binding. +Operator | Level of Precedence | Name +---------------------------------------------------------------- +'' | 6 | Literal string +"" | 6 | Literal string +[] | 6 | Character class +. | 6 | Any character (dot) +// | 6 | Regular expression +() | 6 | Grouping +* | 5 | Repetition (arbitrary) ++ | 5 | Repetition (one or more) +? | 5 | Repetition (zero or one) +& | 4 | And predicate +! | 4 | Not predicate +: | 4 | Label +<>, {} | 3 | Extension +e1 e2 | 2 | Sequence +e1 | e2 | 1 | Ordered choice + += Example + + Below is an example of a simple grammar that is able to parse strings of integers separated by any amount of white space and a + symbol. grammar Addition rule additive @@ -298,19 +321,19 @@ Take a look at examples/calc.citrus for an example of a calculator that is able to parse and evaluate more complex mathematical expressions. - ** Links ** += Links http://mjijackson.com/citrus http://pdos.csail.mit.edu/~baford/packrat/ http://en.wikipedia.org/wiki/Parsing_expression_grammar http://treetop.rubyforge.org/index.html - ** License ** += License Copyright 2010 Michael Jackson Permission is hereby granted, free of charge, to any person obtaining a copy