Ingy döt Net > Pegex-0.20 > lib/Pegex/Syntax.pod


Annotate this POD



Open  0
View/Report Bugs
Source   Latest Release: Pegex-0.63

Pegex Syntax ^

Pegex has a fairly simple set of syntax constructs. This document details them all.

A Pegex grammar is just a set of named rules. They look like this

    rule_name_1: <rule>* <body> /1/
    rule_name_2: /rule body 2/

A rule is a name followed by a ':' followed by a rule body. It can optionally end with a semicolon, if you want to put more than one on a line.

Basic Tokens

Pegex only has 3 kinds of basic tokens:

Rule Reference

A rule reference is the name of a rule inside angle brackets.

Regular Expression

A regular expression is a string inside forward slashes.

    /regular expression/
Error Message

An error message is a string inside backticks.

    `error message`

More to come...

syntax highlighting: