From f2aec5ca1434ff4dc43c51b47faa8347e1ebf3e2 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 4 Jan 2026 23:37:57 -0800 Subject: Better impl --- src/syntax.grammar | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src/syntax.grammar') diff --git a/src/syntax.grammar b/src/syntax.grammar index bffd9c4..ce7ba38 100644 --- a/src/syntax.grammar +++ b/src/syntax.grammar @@ -85,17 +85,18 @@ ProgramEnd { pleaseLikeAndSubscribe } -@skip { space | newline } +@skip { space | newline | Comment } @tokens { space { $[ \t]+ } newline { $[\n\r] } + Comment { "#" (![\n\r] )* } identifierChar { $[A-Z_\-] | $[0-9] | "'" } word { ($[A-Z_\-] | "'") identifierChar* } - @precedence { StringLiteral, NumberLiteral, BooleanLiteral, discoverHowTo, expertsClaim, latestNewsOn, pleaseLikeAndSubscribe, rumorHasIt, shockingDevelopment, whatIf, youWontWantToMiss, toBe, with, of, endOfStory, liesBang, isActually, dividedBy, smallerThan, and, or, plus, minus, times, modulo, beats, Identifier } + @precedence { Comment, StringLiteral, NumberLiteral, BooleanLiteral, discoverHowTo, expertsClaim, latestNewsOn, pleaseLikeAndSubscribe, rumorHasIt, shockingDevelopment, whatIf, youWontWantToMiss, toBe, with, of, endOfStory, liesBang, isActually, dividedBy, smallerThan, and, or, plus, minus, times, modulo, beats, Identifier } Identifier { word } @@ -105,30 +106,30 @@ ProgramEnd { BooleanLiteral { "TOTALLY" space "RIGHT" | "COMPLETELY" space "WRONG" } - discoverHowTo { "DISCOVER" space "HOW" space "TO" } - with { "WITH" } - of { "OF" } - expertsClaim { "EXPERTS" space "CLAIM" } - toBe { "TO" space "BE" } - rumorHasIt { "RUMOR" space "HAS" space "IT" } - whatIf { "WHAT" space "IF" } - liesBang { "LIES!" } - endOfStory { "END" space "OF" space "STORY" } - shockingDevelopment { "SHOCKING" space "DEVELOPMENT" } - youWontWantToMiss { "YOU" space "WON'T" space "WANT" space "TO" space "MISS" } - latestNewsOn { "LATEST" space "NEWS" space "ON" } - pleaseLikeAndSubscribe { "PLEASE" space "LIKE" space "AND" space "SUBSCRIBE" } - - isActually { "IS" space "ACTUALLY" } - and { "AND" } - or { "OR" } - plus { "PLUS" } - minus { "MINUS" } - times { "TIMES" } - dividedBy { "DIVIDED" space "BY" } - modulo { "MODULO" } - beats { "BEATS" } - smallerThan { "SMALLER" space "THAN" } + discoverHowTo[@name="discoverHowTo"] { "DISCOVER" space "HOW" space "TO" } + with[@name="with"] { "WITH" } + of[@name="of"] { "OF" } + expertsClaim[@name="expertsClaim"] { "EXPERTS" space "CLAIM" } + toBe[@name="toBe"] { "TO" space "BE" } + rumorHasIt[@name="rumorHasIt"] { "RUMOR" space "HAS" space "IT" } + whatIf[@name="whatIf"] { "WHAT" space "IF" } + liesBang[@name="liesBang"] { "LIES!" } + endOfStory[@name="endOfStory"] { "END" space "OF" space "STORY" } + shockingDevelopment[@name="shockingDevelopment"] { "SHOCKING" space "DEVELOPMENT" } + youWontWantToMiss[@name="youWontWantToMiss"] { "YOU" space "WON'T" space "WANT" space "TO" space "MISS" } + latestNewsOn[@name="latestNewsOn"] { "LATEST" space "NEWS" space "ON" } + pleaseLikeAndSubscribe[@name="pleaseLikeAndSubscribe"] { "PLEASE" space "LIKE" space "AND" space "SUBSCRIBE" } + + isActually[@name="isActually"] { "IS" space "ACTUALLY" } + and[@name="and"] { "AND" } + or[@name="or"] { "OR" } + plus[@name="plus"] { "PLUS" } + minus[@name="minus"] { "MINUS" } + times[@name="times"] { "TIMES" } + dividedBy[@name="dividedBy"] { "DIVIDED" space "BY" } + modulo[@name="modulo"] { "MODULO" } + beats[@name="beats"] { "BEATS" } + smallerThan[@name="smallerThan"] { "SMALLER" space "THAN" } "(" ")" "," } -- cgit v1.2.3-70-g09d2