diff options
| Commit | 786343ae5bccfd6415e48298bc3b59ae73891d8b (patch) | |
|---|---|---|
| Author | 2023-04-15 10:07:22 +0300 | |
| Committer | 2023-04-15 10:07:27 +0300 | |
| Files | a9184d2a974fe7f5359fc0560c0542ca947cc79c | |
| syndamia.com-786343ae5bccfd6415e48298bc3b59ae73891d8b.tar syndamia.com-786343ae5bccfd6415e48298bc3b59ae73891d8b.tar.gz syndamia.com-786343ae5bccfd6415e48298bc3b59ae73891d8b.zip | ||
| Parent | 01e91bc3caf59f23c28ee0630c3d9b65363fe753 (diff) | |
[blog/seoc] Replaced thick arrow with an arrow that is more readily available on mobile
1 files changed, 6 insertions, 6 deletions
| -rw-r--r-- | src/blog/sane-explanation-of-compilers/part-1.md | 12 |
diff --git a/src/blog/sane-explanation-of-compilers/part-1.md b/src/blog/sane-explanation-of-compilers/part-1.md index 24c87fd..1682807 100644 --- a/src/blog/sane-explanation-of-compilers/part-1.md +++ b/src/blog/sane-explanation-of-compilers/part-1.md @@ -201,7 +201,7 @@ Additionally, there can be multiple rules with the same name, meaning a rule can Always one name is chosen to be the starting point, and generation continues from there. In math literature, generally we write rules in the form `Name -> Expression`[^grammar-syntax], and often names are a single capital letter. Additionally, often the starting name is called `S`. -Finally, in future examples, I'll use the thick arrow `🡆` to show derivations, how the generated string looks after one or two replacements of the name with one of it's expressions. +Finally, in future examples, I'll use the arrow `⇒` to show derivations, how the generated string looks after one or two replacements of the name with one of it's expressions. For an example, with the grammar @@ -213,13 +213,13 @@ S -> cc we can generate the string `aaaaccbbbb` (remember, our starting point is `S`): ```grammar+ -S 🡆 aSb 🡆 aaSbb 🡆 aaaSbbb 🡆 aaaaSbbbb 🡆 aaaaccbbbb +S ⇒ aSb ⇒ aaSbb ⇒ aaaSbbb ⇒ aaaaSbbbb ⇒ aaaaccbbbb ``` or `accb`: ```grammar+ -S 🡆 aSb 🡆 accb +S ⇒ aSb ⇒ accb ``` where a, b and c are just english characters. @@ -236,7 +236,7 @@ E -> N | (E) | E + E | E - E | E * E | E / E | E ^ E which will sucessfully be able to match (generate) `((3 * 3) - (2 ^ 3)) + 2`: ```grammar+ -E 🡆 E + E 🡆 (E) + N 🡆 (E - E) + 2 🡆 ((E) - (E)) + 2 🡆 ((E * E) - (E ^ E)) + 2 🡆 ((N * N) - (N ^ N)) + 2 🡆 ((3 * 3) - (2 ^ 3)) + 2 +E ⇒ E + E ⇒ (E) + N ⇒ (E - E) + 2 ⇒ ((E) - (E)) + 2 ⇒ ((E * E) - (E ^ E)) + 2 ⇒ ((N * N) - (N ^ N)) + 2 ⇒ ((3 * 3) - (2 ^ 3)) + 2 ``` but there are no expressions (rules) that allow `()3+3()` or `)3(-6` to be "matched". @@ -310,11 +310,11 @@ how would it generate `n + n * n`? There are two completely valid ways to do so: ```grammar+ -E 🡆 E + E 🡆 n + E * E 🡆 n + n * n +E ⇒ E + E ⇒ n + E * E ⇒ n + n * n ``` ```grammar+ -E 🡆 E * E 🡆 E + E * n 🡆 n + n * n +E ⇒ E * E ⇒ E + E * n ⇒ n + n * n ``` How exactly we deal with these problems comes later, for now the takeaway is that we have to try and use regular expressions wherever we can, and leave grammars as a bit of a last resort. |