Specification · v1

Limits

v1 is built to sit in an execution path that untrusted input can reach. Every input is bounded, and hostile input is refused in linear time before any recursive parsing.

1. Limits

LimitDefaultCeilingDiagnostic
maxSourceBytes: source size in UTF-8 bytes65,53616 MiBlimit[source-size]
maxNesting: depth of { ( [ outside strings, comments and source tags20256limit[nesting-or-tokens]
maxTokens: words (runs of letters and digits that start with a letter)6,0001,000,000limit[nesting-or-tokens]
maxBooleanOperators: occurrences of the text AND or OR256100,000limit[boolean-tokens]
maxConditionDepth: depth of one clause's condition tree16256limit[condition-depth]

A caller may lower any limit for a call. It cannot raise one past its ceiling. A value outside 1 … ceiling is a usage error.

Condition depth is the exception in ulang-lite 0.1.0: validation reads the top-level maxConditionDepth option, not limits.maxConditionDepth, and that option is not checked against the ceiling (see errata E2).

AND and OR are counted as substrings, so FORBID counts once (it contains OR). The count is a cheap upper bound on work, not a count of operators.

2. The bounds scan

One left-to-right pass over the source with constant state. Strings, // and # comments, and [SOURCE:…] tags are skipped. Everything else is checked, and the first problem found is reported:

  1. empty source, or more than maxSourceBytes (checked first, over the whole source);
  2. the text NOT: unsupported[not-operator];
  3. +, *, / (other than //), ^, or - not directly followed by a digit: unsupported[arithmetic];
  4. more than maxBooleanOperators occurrences of AND/OR;
  5. nesting deeper than maxNesting, or more than maxTokens words.

Items 2 to 5 are checked at each character, so whichever problem occurs earliest in the source is the one reported.

The scan is why NOT and arithmetic produce unsupported diagnostics before any syntax error elsewhere in the file, and why a name that contains NOT anywhere is refused (see Syntax §7).

3. During parsing and validation

Together these bound the parser's stack by maxNesting and each condition's depth by maxConditionDepth, whatever the input.