# Grammar The text of a UJN diagram, from @startujn to @endujn, as a formal grammar: section 22 made exact, and tested on every build of this site. ```ebnf (* ===================================================================================================== UJN grammar: the text of a UI Journey Notation diagram, from @startujn to @endujn. Written for spec revision 23 (proposal/ujn-language-v23.md): section 22 made exact, and checked line by line against the PlantUML module (UjnParser.java, UjnValues.java) and the PlantUML code that reads a file before UJN does (diagram splitting, comments, the preprocessor). Tested by ujn_grammar.py and run_tests.py. --------------------------------------------------------------------------------------------------- The notation of this file --------------------------------------------------------------------------------------------------- name = expression ; a rule. Names are letters, digits, "-" and "_". The first rule is the start. "text" a terminal, matched exactly (case matters). Inside it, \" is a quote, \\ a backslash, \n a line end and \t a tab. /regex/ a lexical class: a Python regular expression, matched at the current place (one match, as Python's re finds it). Inside it, \/ is a slash, and <> stands for the regex of the rule NAME (a rule made of one /regex/). [ e ] e, or nothing. { e } e, zero or more times. ( e ) a group. e1 e2 e1, then e2. e1 | e2 e1 or e2. comments from a left parenthesis and a star to the next star and right parenthesis. A choice and a repetition try every way, not only the first that fits: the grammar is an ordinary context-free grammar over its terminals and lexical classes, read with backtracking. A file is valid when the start rule, `file`, covers all of it. UPPER-CASE names are lexical classes (as in section 22); lower-case names are the syntax. Names that start with raw- are the text the module reads as a value whatever its key; `ujn_grammar.py --strict` drops them, so that every value must take one of the forms of section 5. --------------------------------------------------------------------------------------------------- How a file is read --------------------------------------------------------------------------------------------------- Line ends are "\n". As PlantUML does, the checker reads CR LF and a CR alone as a line end, and drops a byte order mark at the start of the file. The grammar covers files made of printable characters, tabs and line ends. Other control characters (U+0000 to U+001F except tab, line feed and carriage return) and the characters Java treats as line ends inside a line (U+0085, U+2028, U+2029), and U+E103 (a PlantUML line break), are out of scope: the rule SCOPE refuses a file that holds one. Also out of scope, because they are PlantUML features with no place in a UJN file: - @pause, @unpause and @append lines (PlantUML drops or adds lines with them); - a line where @start follows only punctuation, such as `' @startujn` or `# @startujn` (PlantUML starts a diagram there, and removes that punctuation from the lines after it); - inside block comments and preprocessor blocks, and in text outside a diagram, the grammar follows a line that ends with one backslash only as far as noted at each rule. --------------------------------------------------------------------------------------------------- What the grammar covers, and what it leaves to the module --------------------------------------------------------------------------------------------------- The grammar follows the module's parser line by line, and the PlantUML steps before it: how a file is cut into diagrams, which lines are comments, which lines the preprocessor takes. Everything the module only warns about (21) is valid here: an unknown key, a key that does not apply, a value of the wrong kind, a missing title. Which value form a key takes depends on the key (section 5 and the key tables of each section), so `value` lists every form of section 5 and ends with `raw-value`. Left to the module, because they need more than a grammar: - two nodes with the same handle, display id, unique id or friendly id, and an arrow to a handle that no statement declares (syntax errors in the module, 21); - what the preprocessor does with the lines it takes. They are skipped here, not run: an !if without its !endif (or an !endif, !else or !endwhile alone), a failed !assert, a missing !include or theme, a Python error, or a function without !return is not caught (pinned in differ/, named module-only-preprocessor-...); - two module bugs, where the module crashes: a number too large for it (`view_start: 99999999999`), and a block comment or preprocessor block that is never closed after the journey line alone (pinned in differ/, named module-only-crash-...). Stricter than the module on purpose (each case is pinned by a file in differ/, named module-reads-...): - a guard that starts with a double quote and is not one closed string (`"x" or "y`, `"abc`): the module checks only the first character (a module bug); - a guard that starts with [ and has no ] (`: [Save`), or that starts with [ after a trigger; and, after a trigger whose double quote is not closed, a guard that holds a double quote other than as one closed string; - a line that ends with one backslash: PlantUML joins it to the next line before UJN reads it; - braces that do not pair, on a line that ends with }: a line that closes a block (`title: a } b }`), a block that opens and closes on one line (`view a { title: x }{{auto}}`), or a line that opens a block; and a value where a brace pair holds a square bracket that does not pair (`title: {[}`); - lines the preprocessor writes: the grammar reads a preprocessor line as a line to skip, and every other line as written, so a statement that a macro, a procedure, an !foreach, the branch of an !if that is not taken, or a !{...} line writes is not seen; - a /'''name'''/ comment inside a word (PlantUML removes it anywhere; the grammar only between tokens). ===================================================================================================== *) (* ---------------------------------------------------------------- the file and its diagrams (2, 3) *) (* As PlantUML does, a file may hold text outside its diagrams, other PlantUML diagrams, and more than one UJN diagram. A diagram runs from a line that starts with @start (or \start) to the next line that starts with @end (or \end); one that a new @start line interrupts is dropped. *) file = SCOPE { outside } diagram { outside | diagram } ; SCOPE = /(?![\s\S]*[\x00-\x08\x0B\x0C\x0E-\x1F\x85\u2028\u2029\uE103])/ ; outside = OUTSIDE-LINE | OTHER-DIAGRAM | DROPPED-START ; OUTSIDE-LINE = /(?!<>)(?:[^\n]*(?>)[^\n]*\n)*[ \t]*[@\\]end[^\n]*(?:\n|(?![\s\S]))/ ; DROPPED-START = /<>[^\n]*\n(?:(?!<>)[^\n]*\n)*(?:(?=<>)|(?!<>)[^\n]*(?![\s\S]))/ ; (* a start line with no end line before the next start line or the end of the file *) START = /[ \t]*[@\\]start[^\n]/ ; DIRECTIVE = /[ \t]*[@\\](?:start[^\n]|end)/ ; (* a start line or an end line *) LINE = /[^\n]*(?>)<>)*---/ NL ; (* a PlantUML header right after the start line: lines between two lines that are exactly --- *) (* ---------------------------------------------------------------- lines to skip (2) *) skip = blank-line | comment-line | block-comment | preproc ; blank-line = _ NL ; comment-line = /[ \t]*'[^\n]*/ NL ; (* first non-blank character is ' *) block-comment = /[ \t]*\/'[^\n]*'\/[ \t]*\n/ (* a line that starts with /' and ends with '/ *) | /[ \t]*\/'\/[ \t]*\n/ (* a line that holds only /'/ is blank *) | /[ \t]*\/'(?!\/)(?![^\n]*'\/)<>(?:(?!<>)(?![^\n]*'\/[ \t]*\n)<>)*(?:(?!<>)[^\n]*'\/[ \t]*\n|(?=[ \t]*[@\\]end))/ ; (* /' on a line with no '/, then every line up to the first that ends with '/; with none, the rest of the diagram (PlantUML drops it) *) (* The preprocessor takes these lines; the grammar skips them without running them. *) preproc = /[ \t]*(?:<>[ \t]*)?!(?:<>)<>(?:(?!<>)(?!<>)<>)*(?:<><>|(?=[ \t]*[@\\]end))/ (* a procedure, a function or a definelong, up to the first !endprocedure, !endfunction or !enddefinelong (any of the three); with none, the rest of the diagram *) | /[ \t]*!python[ \t]*\n(?:(?!<>)(?![ \t]*!endpy[ \t]*\n)<>)*[ \t]*!endpy[ \t]*\n/ | /[ \t]*(?:<>[ \t]*)?!/ pp-line /[^\n]*/ NL | /[ \t]*!exit[ \t]*\n(?:(?!<>)<>)*(?=[ \t]*[@\\]end)/ ; (* !exit: PlantUML drops the rest of the diagram *) PP-OPENER = /(?:(?:unquoted|final)[ \t])*procedure[ \t]+\$?[^\W\d]\w*[ \t]*\(|(?:(?:unquoted|final)[ \t])*function[ \t]+\$?[^\W\d]\w*[ \t]*\((?![^\n]*\)[ \t]*!?return\b)|definelong[ \t]+[^\W\d]/ ; PP-CLOSER = /[ \t]*!end[ \t]*(?:function|definelong|procedure)\b/ ; (* The one-line directives, after the ! (TLineType and PythonLine in PlantUML). Any other line that starts with ! (`!pragma`, `!!x`, `!{...}`, `! if`, `!define` alone, `!return` outside a function) is handed to UJN, which refuses it. *) pp-line = /[ \t]*[(\[0-9@]/ (* a Python statement or decorator *) | /[ \t]*(?!<>)[^\W\d]/ (* a Python statement: !x = 1, !print(...) *) | /define[ \t]+[^\W\d]/ | /(?:ifdef|undef|ifndef|assert|if|else|elseif|endif|while|endwhile|foreach|endfor|theme|includedef|import|startsub|endsub|includesub|log|dump_memory|option)\b/ | /include[ \t]*(?:url|_many|_once)?\b/ | /end[ \t]*(?:function|definelong|procedure)\b/ | /[ \t]*(?:(?:local|global)[ \t]+\$?[^\W\d]\w*|\$[^\W\d]\w*)[ \t]*\??=/ | /[ \t]*[^\W\d]\w*[ \t]*\?=/ | /(?:(?:unquoted|final)[ \t])*function[ \t]+\$?[^\W\d]\w*[ \t]*\((?=[^\n]*\)[ \t]*!?return\b)/ ; (* a function and its !return on one line *) PP-WORD = /(?:python|endpy|define|definelong|enddefinelong|undef|ifdef|ifndef|if|elseif|else|endif|while|endwhile|foreach|endfor|function|procedure|unquoted|final|end|endfunction|endprocedure|return|include|includeurl|include_many|include_once|include_sprites|includedef|includesub|import|startsub|endsub|theme|log|dump_memory|option|assert|local|pragma|assume|exit)(?!\w)/ ; (* ---------------------------------------------------------------- the start and end of a content line *) (* PlantUML removes block comments before UJN reads a line, without looking at quotes: - a line that starts with /' and ends with '/ is a comment (block-comment above); - a line that starts with /' : the comment runs to the first '/ (it may share the ', as in /'/); - a line that ends with '/ : the comment runs from the last /' (TCUT); - a /'''name'''/ comment (letters, digits, _ and -) is removed from the rest of the line. Then UJN removes a comment that starts with a ' after a blank, outside double quotes. (2) *) lead = /[ \t]*/ [ LEAD-COMMENT _ ] ; LEAD-COMMENT = /\/'(?![^\n]*'\/[ \t]*\n)(?:\/|(?!\/)(?:(?!'\/)[^\n])*'\/)/ ; line-end = ( WS "'" COMMENT-TEXT | _ ) [ TAIL-COMMENT ] NL ; quoted-end = _ [ TAIL-COMMENT ] NL ; (* a line that ends inside double quotes: a ' is text there, not a comment *) COMMENT-TEXT = /(?:(?!<>)[^\n])*/ ; TAIL-COMMENT = /(?=<>)[^\n]*/ ; TCUT = /\/'(?:(?!\/')[^\n])*(?<='\/)[ \t]*\n/ ; (* from the last /' of a line that ends with '/ to the line end. No text class below runs into it, so such a line can only end with TAIL-COMMENT. *) (* ---------------------------------------------------------------- the journey line (3) *) journey-line = lead "journey" WS JOURNEY-ID WS STRING line-end ; journey-entry = lead /(?!journey[ \t])/ KEY _ ":" [ _ journey-value ] line-end ; (* one entry per line, and the colon is required. A line that starts with journey and a blank is read as a journey line, so the key is not journey there. *) journey-value = value | raw-line-value ; (* ---------------------------------------------------------------- statements (4, 6, 10.2, 13, 19.1) *) top-statement = lead top-head block-part ; statement = lead ( top-head | node-head | arrow-head ) block-part | lead ( node-head-q | arrow-head-q ) quoted-end [ later-block ] ; (* a header that ends inside double quotes: its block, if any, opens on a later line *) top-head = "increment" | "render" | COLOR-BLOCK ; COLOR-BLOCK = /(?:view|actor|system|action|handoff|data|start|end|ref|arrow)_color(?:_[a-z][a-z0-9-]*)?/ ; (* _color, _color_, arrow_color, arrow_color_; a suffix that is not a type of the kind is a warning *) node-head = KIND WS HANDLE [ _ "[" DISPLAY-ID "]" ] ; node-head-q = KIND WS HANDLE _ "[" DISPLAY-ID BRACKET-QUOTE-TAIL "]" ; KIND = "view" | "actor" | "system" | "action" | "handoff" | "data" | "start" | "end" | "ref" ; arrow-head = HANDLE WS TOKEN WS HANDLE [ _ ":" [ _ label ] ] ; arrow-head-q = HANDLE WS TOKEN WS HANDLE _ ":" _ label-q ; TOKEN = "-->" | "->" | "-x->" | "..>" | ".>" | ".x.>" | "-" DIR "->" | "-" DIR "-x->" | "." DIR ".>" | "." DIR ".x.>" ; (* 6 + 4 x 8 = 38 tokens *) DIR = "right" | "left" | "up" | "down" | "r" | "l" | "u" | "d" ; label = trigger [ _ guard ] | guard ; (* a trigger, a guard, or both (13.4) *) label-q = "[" BRACKET-TEXT BRACKET-QUOTE-TAIL "]" [ _ ( GUARD-STRING-Q | GUARD-TEXT-Q ) ] | [ trigger _ ] GUARD-TEXT GUARD-QUOTE-TAIL ; (* a trigger or a guard with a double quote that is not closed *) trigger = "[" BRACKET-TEXT "]" ; guard = STRING | GUARD-TEXT ; (* quote a guard that holds ; { } or ' *) (* ---------------------------------------------------------------- blocks (4.4) *) (* A statement's block opens with { on its line, or alone at the start of a later line, with only lines to skip between. Entries are key: value, one per line or separated by ;. A key on its own means true. The block closes on a line that ends with } and holds more } than {, outside double quotes; a block that opens and closes on one line holds as many { as }. *) block-part = _ block | line-end [ later-block ] ; later-block = { skip } lead block ; block = "{" _ [ entries _ ] "}" line-end (* on one line *) | "{" [ _ open-entries ] line-end (* over several lines *) { skip | block-line } closing-line ; block-line = lead open-entries line-end ; closing-line = lead [ entries _ ] "}" line-end ; (* Entries are split at each ; outside double quotes and square brackets. A [ or ] without its partner keeps the ; after it in the value (raw-open-bracket). *) entries = [ semis _ ] entry { semis _ entry } [ semis ] | semis (* empty entries are dropped *) | [ semis _ ] { entry semis _ } KEY _ ":" _ [ raw-value ] raw-open-bracket ; (* On a line that leaves the block open, two more things are text: a double quote that is not closed (the rest of the line is then the value), and a brace without its partner, when the line does not end with }. *) open-entries = [ semis _ ] open-entry { semis _ open-entry } [ semis ] | semis | [ semis _ ] { open-entry semis _ } KEY _ ":" _ [ raw-open-value ] ( raw-open-bracket [ raw-quote-tail ] | raw-quote-tail ) | raw-free-entries /(?>)[^ \t\n;,"'{}\[\]])+/ ; (* kind:reference (9.2) *) handle = HANDLE ; (* one declared in the journey *) text = STRING | BARE-TEXT ; (* What the module reads as a value, whatever the key: the rest of the entry. Braces pair up on the line; square brackets pair up, or pair the other way round (] ... [), and a ; inside them is text; a ' after a blank starts a comment. A value outside the forms above is a warning (21), never a syntax error. *) raw-value = raw-piece { raw-piece } ; raw-piece = raw-flat | raw-braces | raw-square | raw-reversed ; raw-flat = /[^ \t\n"'\/;{}\[\]]+/ | SLASH | APOSTROPHE | INNER-BLANKS | STRING ; raw-braces = "{" { raw-flat | raw-braces | raw-square } "}" ; raw-square = "[" { raw-flat | raw-braces | raw-square | ";" } "]" ; raw-reversed = "]" { raw-flat | raw-flat-braces | ";" | raw-reversed } "[" ; raw-flat-braces = "{" { raw-flat | raw-flat-braces } "}" ; raw-open-bracket = raw-open-square | raw-open-reversed ; raw-open-square = "[" { raw-flat | raw-braces | raw-square | ";" } [ raw-open-square ] ; raw-open-reversed = "]" { raw-flat | raw-flat-braces | ";" | raw-reversed } [ raw-open-reversed ] ; raw-quote-tail = /"(?:(?!<>)(?:[^"\\\n]|\\[^\n]))*/ ; (* a double quote that is not closed, and the rest of the line *) (* On a line that leaves the block open and does not end with }, braces are plain text. *) raw-free-entries = [ semis _ ] raw-free-entry { semis _ raw-free-entry } [ semis ] | [ semis _ ] { raw-free-entry semis _ } KEY _ ":" _ [ raw-free-value ] ( raw-free-open-bracket [ raw-quote-tail ] | raw-quote-tail ) ; raw-free-entry = KEY [ _ ":" [ _ raw-free-value ] ] ; raw-free-value = raw-free-piece { raw-free-piece } ; raw-free-piece = raw-free-flat | raw-free-square | raw-free-reversed ; raw-free-flat = raw-flat | "{" | "}" ; raw-free-square = "[" { raw-free-flat | raw-free-square | ";" } "]" ; raw-free-reversed = "]" { raw-free-flat | ";" | raw-free-reversed } "[" ; raw-free-open-bracket = raw-free-open-square | raw-free-open-reversed ; raw-free-open-square = "[" { raw-free-flat | raw-free-square | ";" } [ raw-free-open-square ] ; raw-free-open-reversed = "]" { raw-free-flat | ";" | raw-free-reversed } [ raw-free-open-reversed ] ; (* A journey entry takes the rest of its line: ; braces and brackets are plain characters there. *) raw-line-value = { raw-line-piece } ( raw-line-piece | raw-quote-tail ) ; raw-line-piece = /[^ \t\n"'\/]+/ | SLASH | APOSTROPHE | INNER-BLANKS | STRING ; (* ---------------------------------------------------------------- lexical classes (22) *) HANDLE = /(?!(?:view|actor|system|journey|increment|action|handoff|data|start|end|ref)(?![A-Za-z0-9_]))[A-Za-z][A-Za-z0-9_]*/ ; (* letters, digits and _, starting with a letter; not a keyword (4.2) *) KEY = /[a-z][a-z0-9_]*/ ; JOURNEY-ID = /[A-Za-z0-9][A-Za-z0-9._-]*/ ; STRING = /"(?:(?!<>)(?:[^"\\\n]|\\[^\n]))*"/ ; (* \" is a quote; any other backslash pair is read as in a PlantUML label: \n, \\, \t *) (* Three pieces that every unquoted text below shares, so that a comment is never read as text: *) APOSTROPHE = /(?>)\// ; (* a / that does not start TCUT *) (* The text of a display id and of a trigger: anything except ] and a line end. A { outside double quotes would open the block, and a ' after a blank starts a comment. A part in double quotes holds no ]. A double quote that is not closed may end the text (BRACKET-QUOTE-TAIL); the line then ends inside quotes. *) BRACKET-TEXT = { /[^\]\n{"'\/ \t]+/ | SLASH | APOSTROPHE | INNER-BLANKS | /"(?:(?!<>)(?:[^"\\\n\]]|\\[^\n\]]))*"/ } ; BRACKET-QUOTE-TAIL = /"(?:(?!<>)(?:[^"\\\]\n]|\\[^\]\n]))*\\?/ ; DISPLAY-ID = BRACKET-TEXT ; (* A guard without quotes around it: no ; { } or ', and it does not start with [ or ". A part in double quotes inside it holds no ; } or ' either. *) GUARD-TEXT = ( /[^ \t\n"'\/;{}\[]/ | SLASH ) { /[^ \t\n"'\/;{}]+/ | SLASH | INNER-BLANKS | /"(?:[^"\\\n;}']|\\[^\n;}'])*"/ } ; GUARD-QUOTE-TAIL = /"(?:(?!\/')(?:[^"\\\n;}']|\\[^\n;}']))*/ ; (* a double quote that is not closed, and the rest of the guard: no ; } or ' *) (* A guard after a trigger whose double quote is not closed: the guard starts inside quotes. *) GUARD-TEXT-Q = /[^\[" \t\n;}'](?:(?!\/')[^"\n;}'])*/ ; GUARD-STRING-Q = /"[^"\\\n{};']*"/ ; (* Text without quotes (5): no ; { } ' or ", and square brackets in pairs. *) BARE-TEXT = ( /[^ \t\n"'\/;{}\[\]]+/ | SLASH | /\[[^\]\n"'{};]*\]/ ) { /[^ \t\n"'\/;{}\[\]]+/ | SLASH | /\[[^\]\n"'{};]*\]/ | INNER-BLANKS } ; (* A list item without quotes: no , [ ] ; { } ' or ". *) ITEM-TEXT = ( /[^ \t\n"'\/;,{}\[\]]+/ | SLASH ) { /[^ \t\n"'\/;,{}\[\]]+/ | SLASH | INNER-BLANKS } ; (* ---------------------------------------------------------------- characters *) _ = { /[ \t]/ | SPECIAL } ; (* blanks, if any *) WS = { SPECIAL } /[ \t]/ _ ; (* one blank or more *) SPECIAL = /(?!<>)\/'''[-A-Za-z0-9_]*'''\// ; (* PlantUML removes it wherever it stands *) NL = /(?_color and after arrow_color. A suffix that is not a known type gives the warning 'unknown type in ...'. - (section 22 vs grammar) An arrow needs a blank on each side of its token, so a-->b is a syntax error. Section 22 writes HANDLE TOKEN HANDLE without saying so. There are 38 tokens. - (section 22 vs grammar) Section 22 does not define GUARD. In the module and the grammar, a guard is either one closed string, or unquoted text without ; { } or ' that does not start with [ or a double quote. Unquoted text may end with a double quote that is not closed; the line then ends inside quotes, so it can hold no ' comment and no block. The module's message 'Quote a guard that holds { } or an apostrophe' does not mention ;. - (section 22 vs grammar) TRIGGER and DISPLAY-ID are 'any text except ]', with two limits: a { outside double quotes opens the block, and a ' after a blank starts a comment. A double quote that is not closed is allowed, but then nothing except blanks may follow the ] on that line; the block may open on the next line. A display id may be empty ([]). - (section 22 vs grammar) Blank, comment and preprocessor lines may stand before a block's {. Empty blocks and empty entries are allowed (;;, or a ; that leads or trails), and entries may sit on the same line as { or }. A block closes on a line that ends with } and holds more } than {. A block that opens and closes on one line holds as many { as }. - (section 22 vs grammar) Section 2 counts render and the color block names (view_color and so on) as keywords, but the module does not reserve them: view render and view view_color are valid. A handle's letters are ASCII A to Z. - (section 22 vs grammar) Block comments, without regard to quotes: on a line that starts with /', the comment runs to the first '/ (/'/ counts). On a line that ends with '/, the comment runs from the last /'. A line that starts with /' and ends with '/ is all comment, and a /'''name'''/ comment is removed wherever it stands. A /' ... '/ anywhere else in a line is plain text, or a syntax error. A ' comment right after a leading /' '/ comment is a preprocessor error. - (section 22 vs grammar) The file around the diagram is not covered by section 22. As in PlantUML, a file may hold text outside its diagrams, other PlantUML diagrams, and several UJN diagrams. A diagram that a new @start line interrupts is dropped. The start line is @start or \start in lower case, then ujn in any case (@startUJN), then anything (@startujn(id=x), @startujnx). Any line that starts with @end or \end, in lower case, ends the diagram. A YAML header between two --- lines may follow the start line. - (section 22 vs grammar) Line ends may be CR LF, or a CR alone, as PlantUML reads them. A byte order mark at the start of a file is ignored. - (section 22 vs grammar) A block comment, a !procedure, !function or !definelong that is never closed, or an !exit line, makes PlantUML drop the rest of the diagram silently. The grammar does the same. - (section 22 vs grammar) Section 21 says an unknown arrow token gives a message telling you to write the source first. The module gives that message only for a reversed token (b <-- a). For a ==> b it says 'Not a UJN statement'. - (section 5 vs grammar) Section 5 says unquoted text needs quotes only when it holds ;, }, ', a comma inside a list, or blanks at its start or end. The module and the grammar also read {, [, ] and " unquoted, with effects section 5 does not describe. A [ or ] without its partner keeps the ; after it in the same value, so title: Step [1; owner: x is one entry. - (section 5 vs grammar) An unquoted double quote that is not closed takes the rest of the line into the value, ; and } included. So view a { title: 5" screen } leaves the block open, and a later } closes it. On a line of its own inside a block, title: 5" screen reads as section 5 means. - (section 5 vs grammar) A { without its partner is plain text on a line that leaves a block open. A } inside a value, which section 5 says needs quotes, gives only a warning, and the grammar reads it on a line that leaves the block open and does not end with }. - (section 5 vs grammar) A duration may have a decimal number (1.5 h), as the module accepts. Section 5 says 'a number and a unit', and section 5 numbers are digits only. - (section 5 vs grammar) A list must close on the line where it starts. A value outside the section 5 forms is a warning, never a syntax error; ujn_grammar.py --strict accepts only the section 5 forms. - (module accepts, grammar refuses) A guard that starts with a double quote but is not one closed string, such as "x" or "y, "x" ; y, "x" } or "abc. The module checks only the first character and gives no warning; this is a module bug. - (module accepts, grammar refuses) A guard that starts with [ and has no ] (: [Save), or a guard that starts with [ after a trigger (: [Save] [draft]). The module reads these as guards, which hides a missing ] or an extra trigger. - (module accepts, grammar refuses) After a trigger whose double quote is not closed, a guard that holds a double quote, unless the guard is one closed string, as in [say "hi] ok "x. - (module accepts, grammar refuses) A line that ends with one backslash. PlantUML joins it to the next line before UJN reads it, and a comment line that ends this way swallows the next line. The grammar refuses such a line instead of following the join. - (module accepts, grammar refuses) Braces that do not pair, on a line that ends with }. This covers a line that closes a block (title: a } b }), a one-line block with text after it (view a { title: x }{{auto}}), and a line that opens a block (view a { title: a } b }). The module counts the braces and reads these, in surprising ways. - (module accepts, grammar refuses) A value where a brace pair holds a square bracket that does not pair, as in title: {[}. - (module accepts, grammar refuses) Lines that the preprocessor writes. The grammar skips preprocessor lines without running them and reads every other line as written. So it does not see statements written by a macro, a procedure call, an !foreach loop or a !{...} line, and it reads the branch of an !if that is not taken. - (module accepts, grammar refuses) A /'''name'''/ comment inside a word, as in vi/'''x'''/ew a. PlantUML removes it anywhere, while the grammar removes it only between tokens. - (module refuses, grammar accepts) Two nodes with the same handle, display id, unique id or friendly id, and an arrow to a handle that no statement declares. Checking these needs more than a grammar. - (module refuses, grammar accepts) Preprocessor lines that fail when PlantUML runs them. Examples are an !if without !endif, or an !endif, !else or !endwhile alone; a failed !assert; an !include or !theme that cannot be found; a Python error; a function without !return. The grammar only checks that such a line is a preprocessor line. - (module refuses, grammar accepts) A digit string too long for the module, as in increment { auto; view_start: 99999999999 } or a display id VIEW-99999999999. The module crashes; this is a module bug. - (module refuses, grammar accepts) A block comment or preprocessor block that is never closed when only the journey line comes before it. The module crashes; this is a module bug. With any other line before it, the module drops the rest of the diagram, as the grammar does. - (out of scope) Control characters other than tab, line feed and carriage return, the Unicode line separators U+0085, U+2028 and U+2029, and U+E103 are out of scope, and the grammar refuses any file that holds one. The module reads a vertical tab or form feed as a blank, drops control characters at the ends of a line, and breaks some lines at U+0085, U+2028 and U+2029. - (out of scope) PlantUML's @pause, @unpause and @append lines, which drop lines from a diagram or add lines to it. - (out of scope) A line where @start follows only punctuation, such as ' @startujn or # @startujn. PlantUML starts a diagram there and removes that punctuation from the lines after it, so a comment line ' @startuml inside a UJN diagram starts a new diagram. - (out of scope) Inside block comments, inside preprocessor blocks, and in text outside a diagram, the grammar follows a line that ends with one backslash only in the simple cases noted at each rule.