GRAM4001 |
Error |
The body of a repetition can match without consuming input. |
The repetition would not terminate. A word over a wordboundary that can match nothing is a repetition of it, and is said at the boundary's declaration (§4.6). |
GRAM4002 |
Error |
Left recursion the rewrite cannot take. |
Direct left recursion is built, and so is an indirect one through rules that only forward. What is refused is an intermediary that does something of its own, a rule with no alternative to start from, and an alternative recursive on both sides (§4.3). |
GRAM4003 |
Error |
trivia must accept empty input. |
It is inserted between every pair of operands, and a required match would demand whitespace everywhere (§4.5). |
GRAM4005 |
Error |
A name in an element set is not a rule. |
|
GRAM4006 |
Error |
A capture inside a lookahead, or one read there. |
What a lookahead records is dropped whether it matched or not. Capture the lookahead itself: ?=X produces X's value (§3.4). A when inside a lookahead may not yet read a capture made before it, c: X & ?=(when @(c.Length > 0)): the lookahead is a reading of its own and is not handed it. A guard reads nothing and needs no lookahead around it — write it beside the lookahead, and ?!(when @(g)) as when @(!(g)). |
GRAM4007 |
Error |
One name is captured twice with different types. |
A member has one type; give the two captures the same one, or different names (§7.3). A fold step (§4.3) that collects a name another alternative holds once is the same case: one side is a sequence, the other a scalar. |
GRAM4008 |
Error |
A => is not on an alternative, or a rule that builds does not say what type. |
A => builds the rule's value, so it belongs at the end of an alternative, and the rule needs : @T to say what it builds. |
GRAM4009 |
Error |
An alternative is recursive and states no strength while its siblings do. |
A rule uses one convention or the other — levels as rules, or << and >> on every recursive alternative (§4.3.1). |
GRAM4010 |
Error |
A recovery's => has no sequence to put the rejected element in. |
The repetition collects text rather than values. Give the repeated rule a capture of its own, or drop the => and report out of band (§8.2). Said too where the elements build values, no capture holds each one, and the alternative they stand in has no => of the author's — the rule is its text (: @string, or no type) or its extent (: @SourceSpan), or a sequence they do not join: the rejection would be dropped with them. Declare the rule a sequence of them (: T[]) or capture each element. An alternative with its own => says what it builds and is not refused. A rule whose every alternative forwards another rule's value — Line : @T = v: Item => @(v) \| v: Remark => @(v) — builds a value, and is read as one here. A repetition of values captured whole, rows: (Row* recover ';' => …), is its text too (§7.3), and is refused the same way: capture each element, rows: Row* recover ';' => …. |
GRAM4011 |
Error |
A rule's declared type is neither a C# type nor a rule in view. |
§4.1 case 3 takes the value of a rule named here; a C# type is written with @. |
GRAM4012 |
Error |
A capture or a rule's parameter takes one of the supplied names, or one of the names the generated parser gives parameters of its own: parserSource, parserStarts, parserLengths, parserReading, parserLocating, parserWhole. |
Every name the parser supplies to a => or a when, and every one it keeps for itself, begins with parser, which is what that prefix is for (§7.3, §8.2). A capture or a parameter of one of them would be declared beside the generated one. Rename it. |
GRAM4013 |
Error |
A call of a parameterized rule that cannot be built, or a value where a piece of grammar goes. |
The message says which: a value standing where a piece of grammar goes — a value is allowed where a value is expected, a count, an argument of @Method, inside @(…), so drop its type to make it a recognizer; a call with the wrong number of arguments, said at the call; a parameterized rule named without any, Std.Nested for Std.Nested("/*", "*/"), which is no rule until a call gives it its arguments — in a publication too, which names a rule and passes nothing, so a rule that calls it is published instead; a value parameter passed something that is not a value; a count naming a parameter that was given no number; or a call that would specialize for ever (§4.2). |
GRAM4014 |
Error |
A rebinding's replacement produces an incompatible result. |
A rule that reads the replaced one into a type of its own — a declared C# type, a sequence, a constructor — expects the replaced rule's type; so does one that reads a copy of a rule following it (R : B) under a with or a publication's with, whatever its action then does with the value. The message names that reader, the rule it reads and both types. Declare the reader as : Rule of the rule it reads, so that its type follows the replacement (§4.1 case 3), or replace with a rule whose result converts to the expected type (§5.1). |
GRAM4015 |
Error |
An external recognizer has more than one value-returning overload with different T. |
Bare @Name cannot say which is meant; give it one such overload, or none (§7.1). |
GRAM4016 |
Warning |
Two alternatives begin with the same operand, and that operand leads back to the rule. |
A warning, and a choice rather than a mistake. Ordered choice reads the operand once for each alternative, so the reading doubles at every level of nesting. Written as one alternative with the rest of the longer one optional it is read once — but that is a different grammar wherever the operand can give back. See §4.5 on saying a lexeme is read once. |
GRAM4017 |
Error |
Two substitutions each need the other applied first: two rules each contain a with that reaches the other, a namespace's header reaches a with that calls back into the namespace from outside it, or two namespaces' headers each reach, from outside, a rule the other rebinds. |
Neither can be specialized against the other already specialized. Give one of them the rebinding the other was going to apply, or write the substitution as a namespace Name with (…) block around both; for a header, write the rebinding inside the namespace or on a publication (§5.1). |
GRAM4018 |
Warning |
A rule nothing reaches. |
A warning: nothing published names it, no rule the grammar reads calls it, no element set drew its items from it, and no rebinding puts it in place of one — so nothing it says is ever read. Publish it, call it, or delete it. Said only about a grammar that is otherwise sound, because a declaration whose syntax did not come out can leave any rule below it unreached; and never about trivia, wordboundary or the rest of the built-in rules, which are configuration rather than rules a grammar calls; nor about the standard library (Std), which every grammar has whole and few call much of. A grammar that publishes nothing is not asked at all. |
GRAM4019 |
Error |
word in a grammar that never said what continues a word. |
word is a run of whatever wordboundary matches (§4.6), so without one it is a run of nothing: the rule matches everywhere and consumes nothing. Declare the boundary, or say the shape that was actually meant. |
GRAM4020 |
Error |
A when … is … somewhere other than beside the operands of an alternative. |
The condition is answered while the parser is built, and what it decides is whether an alternative is in this parser at all — so an alternative is what it has to be able to delete. Inside a group, a repetition or a capture there is nothing for it to remove. Move it out to the operands of the alternative it belongs to; to guard one element of a group or a repetition, make that element a rule of its own whose alternatives carry the conditions, and call the rule from there — the message says so. |
GRAM4021 |
Error |
A when … is … whose sides are not two listable sets of strings. |
is asks whether two recognizers have a string in common. That is decidable, but this compiler answers it only where each side is a literal, a choice of them, or a rule that is one — which is what a domain and a range are. An error, and the build fails with it: the alternative is kept as though the condition held rather than guessed at, since deciding it either way silently changes what the parser reads. Write each side as one of those. Where a side is a rule declared in a namespace under the name of a domain or a range declared outside it, the message says so: the name in the condition now means the local rule, which shadows the outer one (GRAM3012), and a condition written for the range asks about something else; rename the local rule or write the condition outside the namespace. |
GRAM4022 |
Info |
Every alternative of a rule is ruled out by a condition in this parser. |
Information, not a warning: a construct removed from a dialect has to be removable, and this is what removing one looks like — a grammar written per version does it in nearly every parser it publishes. The rule becomes one that cannot match, so a caller of it fails where the construct is written and nowhere else. Worth a second look only where no removal was meant. |
GRAM4023 |
Error |
A grammar published in more than 64 readings. |
A with that substitutes a rule only conditions ask about makes a reading of the grammar, and the parsers of one rule share one machine told apart by the reading's number — one bit each in a word. Sixty-four is room for every version and product of a real language several times over; publish fewer, or split the grammar. |
GRAM4024 |
Error |
A when that leaves different C# behind in different readings. |
The parsers of one rule share a machine, and a condition decides per reading whether its alternative is there. Where the C# beside it survives in two readings as two different pieces of C#, the C# would have to be told which reading it runs in, and it is not. Write the condition so that the C# that survives is the same wherever it does. |
GRAM4025 |
Error |
A C# method a grammar names cannot be called the way its position calls it. |
A bare @Name is an external recognizer, static bool M(ReadOnlySpan<char> input, ref int pos) or the same with out T value after the position; an [@Name] in an element set is a predicate, static bool M(char c) — any method a character can be passed to (§7.1). It is looked for where the generated call will look: the class the grammar is attached to, the classes around it, what they derive from, and the classes of the grammars it includes. The message says which it is — no method of that name, only methods of another shape or out of reach, or a name the generated class gives a publication's method, which hides any method of that name outside it. Said only where that is certain: a method of the right shape anywhere in the compilation's source is taken to be the one meant, and a grammar compiled without a host is not asked. |
GRAM4026 |
Error |
An explicitly requested buffered input form is unsupported. |
The diagnostic names the unsupported construct or input domain. Existing text and legacy reader forms are not replacements for this explicit request. See syntax §6.3 for the current supported subset. Over bytes that includes a type the grammar makes for a rule from a raw capture: its member is a string, and a raw capture of the byte form is a ReadOnlySpan<byte> that nothing decodes, so the message names the rule and the capture; declare the rule's type and build it with =>. The same holds for a rule declared @string whose => is that capture alone, => @(t), or parserText: the span would be handed back as the string, and the message says to build it with a method the host declares for each input. A recognizer of the host over a span is refused wherever the rule reads it, a recovery's synchronization (recover @M) included. |
GRAM4027 |
Error |
A yield publication cannot safely produce the requested element sequence. |
Publish a complete non-nullable Rule* or Rule+ sequence, optionally through transparent wrappers. Collection factories, outer choices, suffixes, recovery and implicit collection trivia are not supported yet. Use a compatible C# element type after yield : @T. |
GRAM4028 |
Error |
A publication result does not fit its explicit C# contract. |
Choose a compatible base type, interface or array type. The contract changes the public API, not construction. Byte extent publications must also accept byte[]. |
GRAM4029 |
Error |
A mark is placed, or parserState/parserMarks asked for, in a grammar that declares no state. |
A mark is a value of the type state : @T declares, so without one there is nothing to write it in. Declare the type the marks are written in (§7.8). |
GRAM4030 |
Error |
A mark's value names a capture of its own alternative. |
A mark is what the grammar wrote at the site, the same every time the site is reached; a capture is a value of one reading. Place one mark per value, in an alternative each, and let a construction that must tell readings apart name parserMarks (§7.8). |
GRAM4031 |
Error |
A guard in a fold step names another step's name for the value so far, which this step has none of. |
Several steps of one left-recursive rule (§4.3) may capture the leading, self-recursive call under different names; a guard is handed the value so far only under the name its own step gave it. Naming a sibling step's name instead is not bound in this step — give every step that shares a head the same name, or capture the leading call of this step under the name the guard reads. |
GRAM4032 |
Error |
A reference or a length may be read where nothing bound its text. |
Every route to $q or #q binds q before it, in the same alternative (§3.5.1). An option ($q: X)? binds nothing on the route that skips it — $q: (X?) binds "" there; a binding in a repetition whose turns hold more than the binding, ($q: X & ',')*, is read only within its turn — bind the whole run; and a binding in a sibling alternative, or to the right of the reference, does not count. |
GRAM4033 |
Error |
A binding's text read where a value goes. |
$q in C# after => or when, in when … is …, or as an argument, which is read inside another rule; and the binding's name read as C# there, => @(q), which is handed nothing of that name. A binding is read again only as a recognizer, later in the alternative that bound it: capture the text as well, q: ($q: …), or rename one of the two (§3.5.1). The other places a binding cannot stand have numbers of their own, GRAM4060-GRAM4064; they were GRAM4033 before 0.3.0. |
GRAM4034 |
Error |
A binding, reference or length where it is not supported yet. |
Three places not yet supported: a repetition that recovers (recover, §8.2), what such a repetition skips to, or a binding around one, written inside it or in a rule it calls; what trivia is made of once the grammar is cut in two (Lexical = true), which a scanner skips between tokens; and a terminal of such a grammar that binds text but begins with nothing an automaton reads — a lookahead, a host recognizer, a rule that reaches itself first — the message naming the terminal. A terminal that binds text and begins with a literal or a class is begun by the lexer and read whole by its own rule from the token's start (§7.1). A reader or stream form (TextReader, Stream) of a publication reads bindings as its string form does; the automatic windowed reader form beside a find is left out for a rule that reaches a binding rather than refused. |
GRAM4035 |
Error |
A binding, reference or length in a rule read over token kinds. |
Once a grammar is cut into a lexer and a parser (Lexical = true), a rule with trivia reads tokens, and a binding there would bind kinds, not text. Compare two captures with a guard instead, close: Name & when @(close == open), or read the grammar over characters (§3.5.1). |
GRAM4036 |
Error |
A with expression inside an instance of a parameterized rule made only while another rebinding was applied. |
Not supported yet: the instance is made after every with is put in order, and its with was dropped. The message names the instance, the call as written and the substitution that replaced its rule: R = Ns.G with (E = F) where G = E(B) makes F(D), and a with in F's body is what is refused. Write the rebinding where the instance is called, or on the rule's own declaration (§5.1). |
GRAM4037 |
Error |
Std.Nested(open, close) called with arguments a counter cannot tell apart. |
A scanner and a lexer read the pair with a counter, which stops where either delimiter can begin and has to know which one stands there. So both are literals ("…" or "…"i), neither is empty, and they cannot begin at one place: their first characters differ, and differ under folding where a literal folds. Said at the call, the message naming which of these failed; where a parameterized rebinding put it in place (P("<", "<") with (P = Std.Nested)), once at the start of the grammar, naming every reason (§5.2). A refused call is not told anything else: what its empty or overlapping delimiters would make of the library's own text follows from the same mistake. |
GRAM4038 |
Error |
A recover inside a lookahead. |
A lookahead is a reading of its own that answers yes or no, and the rule it is written in plans no recovery for it, so the repetition would be read as a plain one. Name the recovering repetition as a rule and call that rule from the lookahead — a rule plans its own recoveries — or take the recover off (§8.2). Also said where a parameter used inside a lookahead is passed a recovering repetition. |
GRAM4039 |
Error |
A step of a left-recursive rule with no => captures something: its leading call, or an operand after it. |
Without a => on any alternative nothing is folded (§4.3): the value is what the base made, so the leading call names a value so far that nothing builds, and a capture after it would be written once per step into a record that has one place for it. Give every alternative a => that builds the value step by step, or capture only in the alternatives that are not recursive. |
GRAM4040 |
Error |
An argument of a call into a namespace with a header, written outside that namespace, names a rule the header rebinds. |
Not supported yet: the instance is a rule of the namespace, and the header's clone of it rewrites the argument with the rest — Ns.L(B) under B = D read D where B was written, rather than what the argument means where it is written (§5.1). At any depth of the argument (Ns.L(P(B)), Ns.L((Y & B))), through a parameter that passes it on (M(x) = Ns.L(x) called M(B)), under a header the namespace inherits, and where a rebinding is what makes the call one into the namespace (L(B) with (L = Ns.F)). A name the caller's own header binds to the same rule means the same on both sides, and is not refused: a caller inside O with (B = D) passing B into a namespace nested in O, which inherits that binding. Pass a rule the header does not rebind, or write the call inside the namespace if the rebinding is meant. |
GRAM4041 |
Error |
A with expression inside an argument of a parameterized rule. |
Not supported yet: an instance is one rule for every call that passes the same argument, keyed by what the argument lowers to, and a with lowers to its operand alone — so L(D with (D = Y)) and L(D) are one instance, and the rebinding was dropped (§4.2, §5.1). Declare a rule with the rebinding and pass that rule: X = D with (D = Y), then L(X). |
GRAM4042 |
Warning |
A strength on an alternative of a climbing rule reaches no operand. |
A warning. A strength binds the call of the rule an alternative ends with — a when after it does not count — and sets the strength it is read at (§4.3.1). Here the call the alternative may end with is inside an optional, a choice or a repetition (left: E & '?' & mid: E & (':' & right: E)? >> 1), so it is read at 0 and the marker says only at what strength the alternative is entered. Write the alternative twice, once ending with the operand and once without it, to give the operand its strength. |
GRAM4043 |
Warning |
A rule is spelled from single characters where trivia is not empty. |
A warning. Every operand of the rule tests one input item — a class, any, a one-character literal, eol, a call to a rule that is itself one such item, a back-reference, or a group, option, repetition, {} or capture of those — at least one is a class or any, and trivia is woven between two of them, so Std.Digit+ & ('.' & Std.Digit+)? reads 1 . 5 as one number and Letter & (Letter \| Digit)* reads i f as one name (§4.5). Write ~ between the parts, or declare the rule where trivia = none; if the space is meant, write trivia there. Not told: a rule that names trivia, the rules trivia itself is made of, a template's specializations, and runs — Std.Digits & ('.' & Std.Digits)? and Word & ('.' & Word)* have the shape of a dotted name, which only the author can tell from a dotted number. Braces do not silence it: they commit a reading and keep the seams. A single-digit calculator meant to be spaced, Digit & ('+' & Digit)*, is told too; write trivia where the space goes. |
GRAM4044 |
Error |
A recover in a rule the lexer reads. |
Said only where the grammar is cut in two (Lexical = true): the lexer reads a terminal, what a terminal is made of and trivia as the longest match of a regular language, so a repetition there would be read as a plain one, with no element to step over. Recover in the syntax that reads the tokens, or leave Lexical off. Said where each such recover is written, an inner one too (§8.2). |
GRAM4045 |
Error |
A recover inside another one's repetition, or a synchronization with a guard, shares what a rule of its own could not. |
A marked repetition inside another one's element recovers as if it were its own rule there, and that rule cannot read, or be read by, what the rest of the enclosing rule reads while it is being read: a guard inside reading a capture made outside it and not inside it before the guard, a guard outside reading one made inside it, a value built inside it with =>, or a capture of a lookahead inside it. Said where the inner recover is written. Move the part into its own rule and pass it what it needs (§8.2); the enclosing rule's own => may read what was captured inside. A synchronization that holds a guard or a capture is a rule of its own in the same way, and a guard in it reading a capture of the rule around it is said at its recover. |
GRAM4046 |
Error |
A rule that is told where it was written builds a Nullable of a struct. |
An error, said where the rule is written, for a grammar that names a LocationType and has a rule of type S? or Nullable<S> with S a struct implementing it. A Nullable has no property of the interface to write: where every rule is located the generated call did not compile (CS1061), and with UsePerCallLocations the value was boxed, told and handed back without its location. Build the struct itself, make the type a class or a record class, or keep the rule out of the located ones (§6.8). A struct itself is told on the value the rule returns, and is accepted. |
GRAM4047 |
Error |
A literal, or a class item, is U+0000 in a grammar that names eos. |
That character is how this version reads the end of a segment: no segment holds it, so the item could never match. Match the end of a segment with eos. A range or a category that merely holds it, ['\0'..'\u001F'] or \p{Cc}, is read without it and not told (§3.1.1). |
GRAM4048 |
Error |
Text is captured, bound or published across an eos, or parserText or parserInput would hold one. |
A boundary has no character, so there is no text of it to keep. Capture the parts on either side of it, or a value built from them; a capture of a rule that builds a value may span boundaries. Text around a repetition marked recover is taken to hold one, whatever it synchronizes on, and so is what a when inside it reads after its first turn (X? and X{1} have none), or in its synchronization; a when in a rule that builds no value is read as if it stood where the rule is called, whose text it may be handed; the parserText of a left-recursive step is the rule's text from its seed on; a count by a length (X{#q}) is read as any repetition, and one whose most is nought (X{0}) reads nothing, and recovers nothing when it is marked recover. A recover without a => is refused unless it synchronizes on eos: it hands OnRecovered the text it stepped over, which up to eos is the rest of one segment. parserText may be read where what it stands for holds no boundary: a rule's own text inside one segment, a when before the first eos, a recover eos. parserInput is not supplied to such a grammar (§3.1.1). |
GRAM4049 |
Error |
Lexical = true over a grammar that names eos. |
A token cannot reach over the end of a segment, and the end of a segment is not a kind of token. Leave Lexical off for it (§3.1.1). |
GRAM4050 |
Error |
A buffered or byte form is asked of a grammar that names eos. |
Such a grammar reads a list, a sequence or a reader of lines, and nothing else (§6.3). Leave the buffered and byte forms off for it. |
GRAM4051 |
Warning |
trivia is not atomic, and a class beside one of its seams reads a character it reads. |
A warning. A class, any or a negated class at the edge of an operand on either side of a seam — written there, or at the start or the end of the rule that operand calls — admits a character trivia can begin with. A run of such characters can then be split between the two in as many ways as it is long, and since trivia without braces gives back what it read, an input that is refused is read again for every split at every seam: exponentially many times in the number of seams. trivia = ' '* beside Field = [^ ',' \| '\n']+ is the shape, where a few refused rows of a CSV file take seconds. The message names the characters, the class, the rule it is written in and the rule whose seam it stands beside. Write the trivia in braces, trivia = { ' '* }, so that what it reads stays read; or, where that is the rule the trivia forwards to, brace that one. Not said at the end of a braced operand, which keeps what it read (its beginning is still told: the trivia in front of it can give it characters); not for the characters a negative look right in front of an element refuses, (?![' ' \| ','] ~ any); not where the class is joined to its neighbour with ~, where it asks the host ([@IsBlank]), or for a grammar cut in two, whose scanner never gives trivia back (§4.5). |
GRAM4052 |
Warning |
A repetition can read one run of text in two ways. |
A warning. In a grammar that publishes parsers under different substitutions (parse X with (Version = …) as Y), the message ends by naming the publications whose parser reads the repetition, each with the values of its with, since the ambiguity may be in one version's parser and not another's. Over characters a choice and a repetition give back what they read to a later failure, and a rule call does not stop that, so an input that is refused is refused only once every reading of what came before it has been tried. Where a repetition can read some text in two ways — a turn that can end in two places, (X+)*; two alternatives that read the same, ('a' \| 'a' & 'a')+; folding white space optional on both sides of a repeated word, (Cfws? & Word & Cfws?)+ — that text repeated n times has two to the n readings, and a refusal after it tries every one, as does an input accepted only by an alternative after the one that read the run: a URI template's run of literal characters and an address's words were both met this way, at seconds for a few dozen characters. The message is at the rule the repetition is written in, spells the repetition and the shortest text it reads two ways, and is said once a repetition, for the innermost of a nest. Asked of every *, + and count without an upper bound read over characters, and in a grammar cut in two (Lexical = true) of those in rules marked ? only, over kinds; of the author's own rules, not those of an included grammar or the standard library. Not said for a repetition where nothing after it, up to the braces or the look around it, can fail, since its first reading then stands — { (('a' \| 'a' & 'a')+)* }, ?=(('a' \| 'a' & 'a')+) — unless it must take more than one turn or as many as the input says, and can fall short after any reading ({ ('a' \| 'a' & 'a'){#q,} } never succeeds there and so never commits); a repetition whose body is braced, which keeps what a turn read; a repetition marked recover, which commits each turn it finishes (§8.2); a turn the parser reads as one test of one character, as (X \| Y)* is where X and Y each read one; the lexer's terminals; a rule over kinds not marked ?, which answers once (§4); the trivia woven at the seams between operands, which is GRAM4051's (trivia the author joins with ~ is no seam, and is read as any call is); the doubling a recursion drives, which is GRAM4016's; and two runs one after the other, 'a'* & 'a'*, which cut a text in as many ways as it is long and not exponentially many. It can tell too much. A look of more than one character, or a when, that removes one of the two readings is taken as reading nothing; a look of one class (?!'"', ?=eof), a look behind, and the end of a braced run of one class ({ [^ '\n']* }, after which no such character can follow) are asked what they leave, against what a braced or opaque step after them begins with: (X \| X & X)+ with X = { 'a'+ } is not told, since the first X takes the whole run. A repetition whose automaton is past the analysis's budget is not told either. And too little, so silence is no proof. A call to a recursive or braced rule, a back-reference, a recognizer of the host and a call past the inlining budget are each read as one opaque letter that overlaps only itself: (X \| 'a')+ with X recursive and reading a is not told. Calls are followed sixty-four deep and no deeper, and the one past is such a letter too: A0 = 'a' \| 'a' & 'a' under sixty guards Ai = when @(true) & A{i-1} is told in A60+, and under sixty-five is not. Two cures, and they differ. Braces around the repetition or what it repeats keep what a turn read, and so can change the language: {('a' \| 'a' & 'a')+} & 'a' refuses aa, which the unbraced rule reads. Rewriting the repetition so that each text has one reading keeps it: 'a'+ for ('a' \| 'a' & 'a')+, X* for (X+)* (which reads nothing too) and X+ for (X+)+, Cfws? & (Word & Cfws?)+ for the word with folding on both sides. Brace where no input needs a turn read again; rewrite where one may. A warning that is wrong is silenced as any is, #pragma warning disable GRAM4052 around the [Gram] or NoWarn, with the reason beside it; raised to an error as any is, <WarningsAsErrors>GRAM4052</WarningsAsErrors>, /warnaserror, or dotnet_diagnostic.GRAM4052.severity = error in a global analyzer configuration or in the .editorconfig section of the C# file a [Gram] is written in (a [*.gram] section does not reach a grammar file's diagnostics) — the build and dotnet dotgram generate alike (docs/cli.md). |
GRAM4053 |
Error |
A supplied name is written where it is not handed over: parserInput, parserState or parserMarks in a when; one of the parser's own parameters (parserSource, parserReading, …, GRAM4012) anywhere; a rejected element's name (parserMessage, parserLine, …) in a =>; the marks in a recover factory; or a supplied name used as a method, a type or a variable, where it is reserved. |
Each place is handed a fixed set of the names §8.2 lists, and a name outside it would be an undeclared identifier in the generated file. A when runs while the text is read, before what stands over it is settled, and builds no value that could keep the input; a => builds the value of an element that was read, so has none of a rejected one's; a rejected element was never read, so no mark stands over it. |
GRAM4054 |
Info |
Two alternatives of a rule read a nested instance of the rule's own recursion before either can be refused. |
Information. Ordered choice decides by trying, and a trial that fails keeps nothing of what it read. Where two alternatives share a prefix holding a construct the recursion they stand in can occur in again — a bracket whose content the same tower reads — and the token that tells them apart comes after it, the construct is read once per alternative, at every level of a nest: (CASE WHEN c THEN 1 END = 1) read as a value in brackets, refused at =, and read again as a condition in brackets, doubling with the depth (§4.7). The message is at the rule, names the alternatives (for an optional, a repetition or a lookahead, the reading and what follows it) and the shortest text after which both go on reading the same construct, and says what the parser does about it. Over tokens, on the immediate carrier, the reader remembers where the rules of that recursion succeed and what they built, beside the memo of failures, so that every level is read once (Machine.Memo.cs); the message names the rule remembered — the first of the recursion both alternatives enter at one token — and the cost: a store at each of its successes of four tokens or more, and 8 bytes a token for it. Over characters, carried deferred, in a trace build, where a construction may throw (ConstructionsMayThrow), for a lookahead's pair (a reading inside a look is not remembered), where a rule of the recursion reaches a hook naming its context or is marked ?, or where DOTGRAM_NO_SUCCESS_MEMO is defined, nothing is remembered: then the message says why, and that the nest costs its depth's power until the alternatives are written to read the shared text once. Either way the rewrite is shown, and it needs no memo: factor the prefix the alternatives share (A & (X \| Y), GRAM4016), read a bracket's content in one rule and tell what it was by a switch on it, or read the value and then its tail. Whether to rewrite is a measurement: on SQL-92 the rewrite cost more on accepted texts than the memo does. Said for a when on the way too, with a note that the guard may separate the two, since a guard is read as nothing. Bounded, not a proof: the two alternatives are followed over at most fourteen tokens, a rule at most twice on one stack, three thousand states a pair; a shared prefix longer than that before the nested construct is not seen, and silence is no proof. A switch is not an ordered choice and is not asked; a ?! of up to three literals is honoured. Not a warning and never an error: a grammar written this way is correct and, where the memo applies, linear; dotnet_diagnostic.GRAM4054.severity = none hides it, and a hidden hint changes nothing in the parser. |
GRAM4055 |
Error |
positional parse in a grammar that names eos. |
Such a grammar reads its segments joined, which only the parser does, so no position of the caller's can stand in that text and no form begins where it is told (§6.3). Drop positional. |
GRAM4056 |
Error |
A construction's value cannot be the type it is declared to give: a capture handed back whole (=> x, => @(x)) that holds text where an array or a value type is declared, or a generated type where another type is; a grammar's type built with the wrong number of values, or from a capture that cannot be its member (=> Pair(right)); a rule's name built or taken as a type where the grammar generates none for it, because it declares its own type or captures nothing. |
Said on the grammar rather than by the C# compiler in the generated file, and only between types whose every conversion the grammar knows: the types it generates, C#'s own written by their keywords (string, int, …), and arrays of those. A type of the host's on either side may declare a conversion, and is left to the C# compiler. Capture what holds the declared type, hand the generated type one value per capture of its rule, in the order the rule writes them (§3.7, §4.1). What a C# expression makes of a capture is left to the C# compiler. |
GRAM4057 |
Error |
What a rule can begin with does not settle. |
A defect of the compiler's rather than of the grammar: working out the first sets came back to a state it had been in, so it would have gone round for ever instead of settling, and the grammar is refused rather than compiled from an unfinished answer. Every grammar known to do this is refused already as left recursion (GRAM4002); report one that is not. |
GRAM4058 |
Error |
C# in a rule — a guard, a switch's selector, a construction, a mark — names one of the rule's parameters that stands for a piece of grammar: Value(tag) = switch @(Kind(tag)) { … }. |
Such a parameter holds no value C# could read; it used to fail as CS0103 in the generated file. A value is handed by a parameter written with its type, Value(tag: @string), and is a literal or a value the caller was handed itself (§4.2); what the parse produces is captured where the rule is called and handed to a => there. Only the C# the rule's own declaration writes is asked — a guard, a selector, a =>, a mark, a value handed to a call — not what an argument brings in, and a name before a dot counts, when @(item.Length > 0). Nothing is said where the host has something of the name that the C# reads: a member, a field or a method handed on, or a namespace or a type before a dot, System.Math or Math under the grammar's @using System;; with no host to ask (a grammar compiled on its own), nothing is said, and C# that does not compile is the C# compiler's to say on the grammar's line. |
GRAM4059 |
Warning |
A grammar publishes nothing, and nothing includes it. |
A warning. The grammar has no parse, find or yield of any visibility, so its class gets no method to call: it is only of use included by another grammar, and no [Gram] class in the compilation includes it ([GramInclude]) or is derived from its class. Most often a parse was forgotten. A grammar written for other assemblies to include says so with [Gram(ExportGrammar = true)], written out: that a public class exports its grammar by default is not enough, since every public host does. Said once per class, and only where nothing else is wrong: not beside any error the generator reports for the class: in the grammar or the class itself, of any of its readings and variants (GRAM0002 to GRAM0011 among them), or in an attribute on any declaration of it (an option under its 0.2 name, GRAM0012); never of a [GramParserVariant], whose class's [Gram] answers for the grammar. |
GRAM4060 |
Error |
A binding inside a lookahead. |
A lookahead gives back what it read, and its own records with it. Bind outside the lookahead; a reference inside one, ?!$q, reads an outer binding and is fine (§3.5.1). A read after such a binding is not told again as GRAM4032. |
GRAM4061 |
Error |
One name bound twice on one route. |
A name is bound once on each route. Give the second binding another name (§3.5.1). |
GRAM4062 |
Error |
A reference or a length inside its own binding. |
The text is still being bound there. Read it after the binding (§3.5.1). |
GRAM4063 |
Error |
A binding and its reference on two sides of a constructing group. |
A group ( … => … ) builds its value as a rule of its own, and a binding is read only in the rule that bound it. Bind and read on one side (§3.5.1). |
GRAM4064 |
Error |
A binding in a step of a left-recursive rule, or around its leading call to itself. |
The steps are read as a loop of their own, after the base (§4.3). Put the binding and its read in a rule the step calls; for the leading call, in the base or in such a rule (§3.5.1). |
GRAM4065 |
Error |
A piece of grammar, a group or an operator, written where a value goes. |
After =>, in a when, in a with state or in a recover's =>, a value is a name, a call, a literal, or C# after @. (l & r), (l), (l | r) and (l?) are what a rule reads, with no C# to hand over: write an expression as @(…), as in => @(l + r), or => l for a capture handed back whole. |