From cc19a1b9a2c688389e9082c2880d4b6532b2f263 Mon Sep 17 00:00:00 2001 From: Marut Khumtong Date: Wed, 13 Aug 2025 22:37:48 +0700 Subject: [PATCH 1/2] chore: update github badges layout for small screen --- .github/workflows/github-pages.yml | 2 +- platforms/web/src/components/graph_view.rs | 4 ++-- platforms/web/styles.css | 21 +++++++++++---------- platforms/web/turing-editor.js | 1 + 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 644d078..395a3fb 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -3,7 +3,7 @@ name: Release to Github Pages on: push: - branches: [main] + branches: [main, deploy-github-pages] paths: - 'platforms/web/**' - '.github/workflows/github-pages.yml' diff --git a/platforms/web/src/components/graph_view.rs b/platforms/web/src/components/graph_view.rs index 329b7e2..a2c95d1 100644 --- a/platforms/web/src/components/graph_view.rs +++ b/platforms/web/src/components/graph_view.rs @@ -194,7 +194,7 @@ impl GraphView { {{ selector: '.current', style: {{ 'background-color': gt.activeNodeColor }} }}, {{ selector: '.previous', style: {{ 'background-color': gt.defaultNodeColor }} }}, {{ selector: '.halt', style: {{ 'background-color': gt.defaultNodeColor }} }}, - {{ selector: 'edge', style: {{ 'width': 2, 'line-color': gt.edgeColor, 'target-arrow-color': gt.edgeColor, 'target-arrow-shape': 'triangle', 'curve-style': 'bezier', 'font-size': '12px', 'text-background-color': 'white', 'text-background-opacity': 0.8 }} }}, + {{ selector: 'edge', style: {{ 'width': 2, 'line-color': gt.edgeColor, 'target-arrow-color': gt.edgeColor, 'target-arrow-shape': 'triangle', 'curve-style': 'bezier', 'font-family': '"Fira Code", monospace', 'font-size': '12px', 'color': '#444', 'text-background-color': '#F5F7FA', 'text-background-opacity': 0.8 }} }}, {{ selector: 'edge[label]', style: {{ 'label': 'data(label)', 'text-wrap': 'wrap', 'text-max-width': '120px' }} }} ], layout: {{ name: 'circle', padding: 30 }}, @@ -313,6 +313,6 @@ impl GraphView { .collect::>() .join(","); - format!("{}/{}/{}", read_str, write_str, dir_str) + format!("{} -> {}, {}", read_str, write_str, dir_str) } } diff --git a/platforms/web/styles.css b/platforms/web/styles.css index df54e5c..31c3e3b 100644 --- a/platforms/web/styles.css +++ b/platforms/web/styles.css @@ -668,17 +668,16 @@ body { .app { padding: 1.5rem; } + body { + padding-top: 1rem; + } + body .socials { + position: relative; + margin: 0 1rem 0.2rem; + } .main-layout, .left-panel, .right-panel { gap: 1.5rem; } - .card, .program-selector-section, .editor-section, .tape-view, -.state-display, -.control-panel, -.graph-view, -.multi-tape-view, -.status-section { - /* These styles are now handled by .section */ -} .btn { padding: 0.7rem 1.4rem; font-size: 0.9rem; @@ -687,10 +686,12 @@ body { .socials { position: absolute; - top: 1.5rem; - right: 1.5rem; + right: 0; + top: 0; display: flex; + justify-content: flex-end; gap: 5px; + margin: 1.5rem 1.5rem 0 0; z-index: 10; } /* Share Button Styles */ diff --git a/platforms/web/turing-editor.js b/platforms/web/turing-editor.js index 56f5e33..00b7582 100644 --- a/platforms/web/turing-editor.js +++ b/platforms/web/turing-editor.js @@ -13,6 +13,7 @@ window.addEventListener("load", () => { nodeTextColor: "white", edgeTextBackgroundColor: "white", }; + console.log("Graph theme initialized"); // Initialize CodeMirror-based syntax highlighting From 3eec9a20e423e3579899818fcfab0c82ed29e4d2 Mon Sep 17 00:00:00 2001 From: Marut Khumtong Date: Sat, 16 Aug 2025 00:15:31 +0700 Subject: [PATCH 2/2] chore(grammar): support blank lines between rules for readability --- .github/workflows/github-pages.yml | 2 +- README.md | 2 +- src/grammar.pest | 12 ++++++------ src/parser.rs | 6 +++++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 395a3fb..644d078 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -3,7 +3,7 @@ name: Release to Github Pages on: push: - branches: [main, deploy-github-pages] + branches: [main] paths: - 'platforms/web/**' - '.github/workflows/github-pages.yml' diff --git a/README.md b/README.md index d9006ee..2cf8132 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ state: cargo run -p tur-cli -- examples/binary-addition.tur # Pipe input to a program -echo '$011-' | cargo run -p tur-cli -- examples/binary-addition.tur +echo '$011' | cargo run -p tur-cli -- examples/binary-addition.tur # Chaining programs with pipes echo '$011' | cargo run -p tur-cli -- examples/binary-addition.tur | cargo run -p tur-cli -- examples/binary-addition.tur diff --git a/src/grammar.pest b/src/grammar.pest index 3156c79..4202f88 100644 --- a/src/grammar.pest +++ b/src/grammar.pest @@ -41,11 +41,10 @@ state_stop = { "stop:" ~ state ~ ("," ~ state)* } // ============================================================================= // TRANSITIONS SECTION // ============================================================================= -rules = ${ "rules:" ~ transition_block ~ last_transition_block? } -transition_block = _{ block_start ~ (comment | transition+) ~ block_end ~ transition_block* } -transition = ${ state ~ ":" ~ actions+ } -last_transition_block = _{ block_start ~ (comment | last_transition) ~ block_end } -last_transition = ${ state ~ ":" } +rules = ${ "rules:" ~ transition_block ~ (block_sep ~ last_transition)? } +transition_block = _{ block_start ~ transition ~ (block_sep ~ (comment | transition))* ~ block_end ~ transition_block* } +transition = ${ state ~ ":" ~ actions+ } +last_transition = ${ state ~ ":" } // ============================================================================= // ACTIONS AND TRANSITIONS @@ -63,6 +62,7 @@ direction = { "<" | ">" | "-" | "L" | "R" | "S" } // ============================================================================= block_start = _{ NEWLINE ~ PEEK_ALL ~ PUSH(INDENT) } block_end = _{ DROP } +block_sep = _{ NEWLINE+ ~ INDENT } // ============================================================================= // BASIC ELEMENTS @@ -88,6 +88,6 @@ trailing_comment = _{ WHITESPACE+ ~ "#" ~ (!NEWLINE ~ ANY)* } // ============================================================================= // WHITESPACE AND INDENTATION // ============================================================================= -LEADING = { NEWLINE | comment } +LEADING = _{ NEWLINE | comment } INDENT = _{ (" " | "\t")+ } WHITESPACE = _{ " " } diff --git a/src/parser.rs b/src/parser.rs index e559d90..db42228 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -484,7 +484,11 @@ name: Simple Test tape: a rules: start: - a -> b, R, halt + a -> b, R, other + + other: + b -> c, R, halt + halt: "#;