pacc logo


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.


Porting and packaging

One thing pacc needs is more users. And, perhaps, one way to get more users is to reduce the friction in getting started with pacc. An obvious lubricant is packaging. Read More...

Release relief

Looking at _pacc_coords(), I noticed that it seemed to have the same realloc() bug that I'd just fixed in _pacc_result(). However, the "list of arrays" trick really wasn't going to work here. Read More...

See more news articles