

Here's where we've got to, french1.pacc:
Start ← "yes" {1} / "oui" {1} / "non" {0} / "no" {0}
We can improve this by splitting things up. Here's french2.pacc:
Start ← Yes → 1 / No → 0 Yes :: void ← "yes" / "oui" No ← "non" / "no"
Don't, at the moment, worry about :: void on the second line—we'll explain what this means shortly. The important point to notice is that a grammar can have more than one rule. The first rule is always the start rule, where parsing begins.
Each rule has a name, in this grammar there are 3 rules named Start, Yes, and No. Rule names are formed in the same way as C identifiers: they must start with a letter or underscore, and continue with letters, underscores, or digits. I often follow the convention of starting rule names with capital letters as it helps them to stand out, but you don't have to.
One rule can call another simply by naming it. The definition of the Start rule contains two call matchers: the first calls the rule Yes and the second calls the rule No. As you might expect, when you call a rule by name, that matches whatever the called rule matches. You can call a rule before it has been defined, so long as the definition occurs in the same pacc grammar.
Let's look at that in a little more detail. A literal string like "yes" is one kind of matcher. A matcher occurs on the right hand side of a rule, and it matches something in the input. In the case of a literal string, it matches just that one string. So a call to another rule is another kind of matcher. There's only a couple more, which we'll get to soon.
Support the development of pacc with a donation! We accept donations in BitCoin or via PayPal who handle almost any other form of payment.
I'm starting to implement what I'm calling “new-rep”. To begin with, we can gloss over the details of exactly how it will be expressed in pacc, but we will need to decide how it will look in the AST. My first test case will be the unary counting grammar, which might look a bit like this: Read More...
With the help of Dale Schumacher, I have cracked left recursion. At least, I have a paper design that I believe I can implement. I think I will attempt to do this before the next release, as really without it pacc is very hard to use for a number of important cases. It should also make it possible to implement arbitrary counted repetitions, such as {2,4}. As a bonus, this should make certain error messages less opaque. Finally, I believe it to be an original piece of work. Read More...