Skip to content

Commit 3eec9a2

Browse files
committed
chore(grammar): support blank lines between rules for readability
1 parent cc19a1b commit 3eec9a2

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.github/workflows/github-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release to Github Pages
33

44
on:
55
push:
6-
branches: [main, deploy-github-pages]
6+
branches: [main]
77
paths:
88
- 'platforms/web/**'
99
- '.github/workflows/github-pages.yml'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ state:
146146
cargo run -p tur-cli -- examples/binary-addition.tur
147147

148148
# Pipe input to a program
149-
echo '$011-' | cargo run -p tur-cli -- examples/binary-addition.tur
149+
echo '$011' | cargo run -p tur-cli -- examples/binary-addition.tur
150150

151151
# Chaining programs with pipes
152152
echo '$011' | cargo run -p tur-cli -- examples/binary-addition.tur | cargo run -p tur-cli -- examples/binary-addition.tur

src/grammar.pest

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ state_stop = { "stop:" ~ state ~ ("," ~ state)* }
4141
// =============================================================================
4242
// TRANSITIONS SECTION
4343
// =============================================================================
44-
rules = ${ "rules:" ~ transition_block ~ last_transition_block? }
45-
transition_block = _{ block_start ~ (comment | transition+) ~ block_end ~ transition_block* }
46-
transition = ${ state ~ ":" ~ actions+ }
47-
last_transition_block = _{ block_start ~ (comment | last_transition) ~ block_end }
48-
last_transition = ${ state ~ ":" }
44+
rules = ${ "rules:" ~ transition_block ~ (block_sep ~ last_transition)? }
45+
transition_block = _{ block_start ~ transition ~ (block_sep ~ (comment | transition))* ~ block_end ~ transition_block* }
46+
transition = ${ state ~ ":" ~ actions+ }
47+
last_transition = ${ state ~ ":" }
4948

5049
// =============================================================================
5150
// ACTIONS AND TRANSITIONS
@@ -63,6 +62,7 @@ direction = { "<" | ">" | "-" | "L" | "R" | "S" }
6362
// =============================================================================
6463
block_start = _{ NEWLINE ~ PEEK_ALL ~ PUSH(INDENT) }
6564
block_end = _{ DROP }
65+
block_sep = _{ NEWLINE+ ~ INDENT }
6666

6767
// =============================================================================
6868
// BASIC ELEMENTS
@@ -88,6 +88,6 @@ trailing_comment = _{ WHITESPACE+ ~ "#" ~ (!NEWLINE ~ ANY)* }
8888
// =============================================================================
8989
// WHITESPACE AND INDENTATION
9090
// =============================================================================
91-
LEADING = { NEWLINE | comment }
91+
LEADING = _{ NEWLINE | comment }
9292
INDENT = _{ (" " | "\t")+ }
9393
WHITESPACE = _{ " " }

src/parser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,11 @@ name: Simple Test
484484
tape: a
485485
rules:
486486
start:
487-
a -> b, R, halt
487+
a -> b, R, other
488+
489+
other:
490+
b -> c, R, halt
491+
488492
halt:
489493
"#;
490494

0 commit comments

Comments
 (0)