Fix README example grammar
This commit is contained in:
parent
3a8dcac55f
commit
19c32b58dc
47
README.md
47
README.md
@ -17,6 +17,7 @@ can be copied into and versioned in a project's source tree.
|
|||||||
The only requirement to run Propane is that the system has a Ruby interpreter
|
The only requirement to run Propane is that the system has a Ruby interpreter
|
||||||
installed.
|
installed.
|
||||||
The latest release can be downloaded from [https://github.com/holtrop/propane/releases](https://github.com/holtrop/propane/releases).
|
The latest release can be downloaded from [https://github.com/holtrop/propane/releases](https://github.com/holtrop/propane/releases).
|
||||||
|
|
||||||
Simply copy the `propane` executable script into the desired location within
|
Simply copy the `propane` executable script into the desired location within
|
||||||
the project to be built (typically the root of the repository) and mark it
|
the project to be built (typically the root of the repository) and mark it
|
||||||
executable.
|
executable.
|
||||||
@ -55,10 +56,10 @@ import std.math;
|
|||||||
ptype ulong;
|
ptype ulong;
|
||||||
|
|
||||||
# A few basic arithmetic operators.
|
# A few basic arithmetic operators.
|
||||||
token plus /\\+/;
|
token plus /\+/;
|
||||||
token times /\\*/;
|
token times /\*/;
|
||||||
token power /\\*\\*/;
|
token power /\*\*/;
|
||||||
token integer /\\d+/ <<
|
token integer /\d+/ <<
|
||||||
ulong v;
|
ulong v;
|
||||||
foreach (c; match)
|
foreach (c; match)
|
||||||
{
|
{
|
||||||
@ -67,38 +68,22 @@ token integer /\\d+/ <<
|
|||||||
}
|
}
|
||||||
$$ = v;
|
$$ = v;
|
||||||
>>
|
>>
|
||||||
token lparen /\\(/;
|
token lparen /\(/;
|
||||||
token rparen /\\)/;
|
token rparen /\)/;
|
||||||
# Drop whitespace.
|
# Drop whitespace.
|
||||||
drop /\\s+/;
|
drop /\s+/;
|
||||||
|
|
||||||
Start -> E1 <<
|
Start -> E1 << $$ = $1; >>
|
||||||
$$ = $1;
|
E1 -> E2 << $$ = $1; >>
|
||||||
>>
|
E1 -> E1 plus E2 << $$ = $1 + $3; >>
|
||||||
E1 -> E2 <<
|
E2 -> E3 << $$ = $1; >>
|
||||||
$$ = $1;
|
E2 -> E2 times E3 << $$ = $1 * $3; >>
|
||||||
>>
|
E3 -> E4 << $$ = $1; >>
|
||||||
E1 -> E1 plus E2 <<
|
|
||||||
$$ = $1 + $3;
|
|
||||||
>>
|
|
||||||
E2 -> E3 <<
|
|
||||||
$$ = $1;
|
|
||||||
>>
|
|
||||||
E2 -> E2 times E3 <<
|
|
||||||
$$ = $1 * $3;
|
|
||||||
>>
|
|
||||||
E3 -> E4 <<
|
|
||||||
$$ = $1;
|
|
||||||
>>
|
|
||||||
E3 -> E3 power E4 <<
|
E3 -> E3 power E4 <<
|
||||||
$$ = pow($1, $3);
|
$$ = pow($1, $3);
|
||||||
>>
|
>>
|
||||||
E4 -> integer <<
|
E4 -> integer << $$ = $1; >>
|
||||||
$$ = $1;
|
E4 -> lparen E1 rparen << $$ = $2; >>
|
||||||
>>
|
|
||||||
E4 -> lparen E1 rparen <<
|
|
||||||
$$ = $2;
|
|
||||||
>>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Grammar files can contain comment lines beginning with `#` which are ignored.
|
Grammar files can contain comment lines beginning with `#` which are ignored.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user