diff --git a/src/grammar/ursa.ohm b/src/grammar/ursa.ohm index 95c13ad..3b7f533 100644 --- a/src/grammar/ursa.ohm +++ b/src/grammar/ursa.ohm @@ -29,11 +29,11 @@ Ursa { Definition = ident Initializer Initializer = "=" Exp - List = "[" ListOf ","? "]" + List (a list) = "[" ListOf ","? "]" - Object = NamedType? "{" ListOf #sc "}" + Object (an object) = NamedType? "{" ListOf #sc "}" - Map = "{" ListOf ","? "}" + Map (a map) = "{" ListOf ","? "}" KeyValue = Exp ":" Exp PostfixExp @@ -45,8 +45,8 @@ Ursa { Ifs = NonemptyListOf (else Block)? If = if Exp Block - Fn = FnType Block - FnType = (fn | gen) "(" ListOf ","? ")" TypeAnnotation? + Fn (a function) = FnType Block + FnType (a function type) = (fn | gen) "(" ListOf ","? ")" TypeAnnotation? Param = ident TypeAnnotation? Loop = loop Block @@ -127,7 +127,7 @@ Ursa { Use = use Path - Block = "{" Sequence "}" + Block (a block) = "{" Sequence "}" // Types NamedType = Path TypeArgs? @@ -186,7 +186,7 @@ Ursa { reservedWord = bool | null | keyword // Make ident indirect so we can easily get a node with the whole identifier. - ident = identName + ident (an identifier) = identName identName = ~reservedWord identifierStart identifierPart* identifierStart = letter | "_" identifierPart = identifierStart | digit @@ -195,13 +195,13 @@ Ursa { null = "null" ~identifierPart - bool = ("false" | "true") ~identifierPart + bool (a boolean) = ("false" | "true") ~identifierPart - number + number (a number) = digit* "." digit+ -- fract | digit+ -- whole - string = "\"" stringCharacter* "\"" + string (a string) = "\"" stringCharacter* "\"" stringCharacter = ~("\"" | "\\" | lineTerminator) any -- nonEscaped | "\\" escapeSequence -- escaped @@ -224,19 +224,19 @@ Ursa { = "x" hexDigit hexDigit unicodeEscapeSequence = "u" hexDigit hexDigit hexDigit hexDigit - lineTerminator + lineTerminator (a line terminator) = "\n" | "\r" | "\x0B" | "\x0C" | "\u2028" | "\u2029" lineTerminatorSequence = "\n" | "\r" ~"\n" | "\x0B" | "\x0C" | "\u2028" | "\u2029" | "\r\n" - literalString + literalString (a literal string) = "r\"" (~"\"" any)* "\"" | "r#\"" (~"\"#" any)* "\"#" | "r##\"" (~"\"##" any)* "\"##" | "r###\"" (~"\"###" any)* "\"###" | "r####\"" (~"\"####" any)* "\"####" - comment = blockComment | lineComment + comment (a comment) = blockComment | lineComment blockComment = "/*" (~("*/" | "/*") any)* blockComment? (~"*/" any)* "*/" lineComment = "//" (~lineTerminator any)* @@ -246,7 +246,7 @@ Ursa { // Does not accept lineTerminators spacesNoNL = (whitespace | comment)* - whitespace + whitespace (whitespace) = "\t" | " " | "\u00A0" -- noBreakSpace diff --git a/src/grammar/ursa.ohm-bundle.d.ts.diff b/src/grammar/ursa.ohm-bundle.d.ts.diff index 023c0ca..06a6d4f 100644 --- a/src/grammar/ursa.ohm-bundle.d.ts.diff +++ b/src/grammar/ursa.ohm-bundle.d.ts.diff @@ -1,5 +1,5 @@ ---- src/grammar/ursa.ohm-bundle.d.ts 2024-08-20 16:44:30.436461339 +0100 -+++ src/grammar/ursa.ohm-bundle.d.part-patched.ts 2024-08-20 16:44:30.564461957 +0100 +--- src/grammar/ursa.ohm-bundle.d.ts 2024-08-27 21:08:34.518891120 +0100 ++++ src/grammar/ursa.ohm-bundle.d.part-patched.ts 2024-08-27 21:08:34.658891700 +0100 @@ -4,14 +4,33 @@ import { BaseActionDict, diff --git a/test/repl-syntax-error.stderr b/test/repl-syntax-error.stderr index 5a92746..61616a3 100644 --- a/test/repl-syntax-error.stderr +++ b/test/repl-syntax-error.stderr @@ -1,4 +1,4 @@ Line 1, col 4: > 1 | 4 + ^ -Expected "(", "gen", "fn", "{", "[", "_", a letter, a digit, ".", "r####\"", "r###\"", "r##\"", "r#\"", "r\"", "\"", "true", "false", "null", "-", "+", or "~" \ No newline at end of file +Expected "(", a function, a block, a list, an identifier, an object, a map, a number, a literal string, a string, a boolean, "null", "-", "+", or "~" \ No newline at end of file