this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

doc/ref: annotate EBNF code blocks via their triple backticks

THe main benefit here is that we can start being clear about
what language syntax is used for each code block,
so that we can then start applying validations and formatting
in later CLs.

We don't plan to do anything with EBNF yet, but at least this further
ensures that we don't mistakenly treat any of these as CUE syntax.

A nice side benefit of this change is that Hugo's HTML rendering
seems to support EBNF syntax highlighting, so the result is nicer.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ifbbf5be6e3b7c51d097d01c7d0b14b14a6ff8657
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1232177
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+20 -20
+20 -20
doc/ref/spec.md
··· 51 51 52 52 The syntax is specified using Extended Backus-Naur Form (EBNF): 53 53 54 - ``` 54 + ```ebnf 55 55 Production = production_name "=" [ Expression ] "." . 56 56 Expression = Alternative { "|" Alternative } . 57 57 Alternative = Term { Term } . ··· 107 107 108 108 The following terms are used to denote specific Unicode character classes: 109 109 110 - ``` 110 + ```ebnf 111 111 newline = /* the Unicode code point U+000A */ . 112 112 unicode_char = /* an arbitrary Unicode code point except newline */ . 113 113 unicode_letter = /* a Unicode code point classified as "Letter" */ . ··· 124 124 125 125 The underscore character `_` (U+005F) is considered a letter. 126 126 127 - ``` 127 + ```ebnf 128 128 letter = unicode_letter | "_" | "$" . 129 129 decimal_digit = "0" … "9" . 130 130 binary_digit = "0" … "1" . ··· 199 199 Identifiers are normalized using the NFC normal form. 200 200 --> 201 201 202 - ``` 202 + ```ebnf 203 203 identifier = [ "#" | "_#" ] letter { letter | unicode_digit } . 204 204 ``` 205 205 ··· 289 289 290 290 There are several kinds of numeric literals. 291 291 292 - ``` 292 + ```ebnf 293 293 int_lit = decimal_lit | si_lit | octal_lit | binary_lit | hex_lit . 294 294 decimal_lit = "0" | ( "1" … "9" ) { [ "_" ] decimal_digit } . 295 295 decimals = decimal_digit { [ "_" ] decimal_digit } . ··· 443 443 444 444 All other sequences starting with a backslash are illegal inside literals. 445 445 446 - ``` 446 + ```ebnf 447 447 escaped_char = `\` { `#` } ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | "/" | `\` | "'" | `"` ) . 448 448 byte_value = octal_byte_value | hex_byte_value . 449 449 octal_byte_value = `\` { `#` } octal_digit octal_digit octal_digit . ··· 858 858 Implementations may associate error strings with different instances of bottom; 859 859 logically they all remain the same value. 860 860 861 - ``` 861 + ```ebnf 862 862 bottom_lit = "_|_" . 863 863 ``` 864 864 ··· 883 883 It has only one parent, top, and one child, bottom. 884 884 It is unordered with respect to any other value. 885 885 886 - ``` 886 + ```ebnf 887 887 null_lit = "null" . 888 888 ``` 889 889 ··· 901 901 The predeclared boolean type is `bool`; it is a defined type and a separate 902 902 element in the lattice. 903 903 904 - ``` 904 + ```ebnf 905 905 bool_lit = "true" | "false" . 906 906 ``` 907 907 ··· 1046 1046 A struct literal may contain multiple fields with the same label, 1047 1047 the result of which is the unification of all those fields. 1048 1048 1049 - ``` 1049 + ```ebnf 1050 1050 StructLit = "{" { Declaration "," } "}" . 1051 1051 Declaration = Field | Ellipsis | Embedding | LetClause | attribute . 1052 1052 Ellipsis = "..." [ Expression ] . ··· 1577 1577 within the [scope](#declarations-and-scopes) in which they are declared. 1578 1578 The name of an alias must be unique within its scope. 1579 1579 1580 - ``` 1580 + ```ebnf 1581 1581 AliasExpr = [ identifier "=" ] Expression . 1582 1582 ``` 1583 1583 ··· 1733 1733 The length of an open list is the number of elements as a lower bound 1734 1734 and an unlimited number of elements as its upper bound. 1735 1735 1736 - ``` 1736 + ```ebnf 1737 1737 ListLit = "[" [ ElementList [ "," ] ] "]" . 1738 1738 ElementList = Ellipsis | Embedding { "," Embedding } [ "," Ellipsis ] . 1739 1739 ``` ··· 1966 1966 An operand may be a literal, a (possibly qualified) identifier denoting 1967 1967 a field, alias, or let declaration, or a parenthesized expression. 1968 1968 1969 - ``` 1969 + ```ebnf 1970 1970 Operand = Literal | OperandName | "(" Expression ")" . 1971 1971 Literal = BasicLit | ListLit | StructLit . 1972 1972 BasicLit = int_lit | float_lit | string_lit | ··· 1978 1978 1979 1979 A qualified identifier is an identifier qualified with a package name prefix. 1980 1980 1981 - ``` 1981 + ```ebnf 1982 1982 QualifiedIdent = PackageName "." identifier . 1983 1983 ``` 1984 1984 ··· 2019 2019 2020 2020 Primary expressions are the operands for unary and binary expressions. 2021 2021 2022 - ``` 2022 + ```ebnf 2023 2023 PrimaryExpr = 2024 2024 Operand | 2025 2025 PrimaryExpr Selector | ··· 2195 2195 2196 2196 Operators combine operands into expressions. 2197 2197 2198 - ``` 2198 + ```ebnf 2199 2199 Expression = UnaryExpr | Expression binary_op Expression . 2200 2200 UnaryExpr = PrimaryExpr | unary_op UnaryExpr . 2201 2201 ··· 2626 2626 struct. 2627 2627 Both structs and lists may contain multiple comprehensions. 2628 2628 2629 - ``` 2629 + ```ebnf 2630 2630 Comprehension = Clauses StructLit . 2631 2631 2632 2632 Clauses = StartClause { [ "," ] Clause } . ··· 3080 3080 it will be output instead of its enclosing file when exporting CUE 3081 3081 to a data format 3082 3082 3083 - ``` 3083 + ```ebnf 3084 3084 SourceFile = { attribute "," } [ PackageClause "," ] { ImportDecl "," } { Declaration "," } . 3085 3085 ``` 3086 3086 ··· 3097 3097 A package clause is an optional clause that defines the package to which 3098 3098 a source file the file belongs. 3099 3099 3100 - ``` 3100 + ```ebnf 3101 3101 PackageClause = "package" PackageName . 3102 3102 PackageName = identifier . 3103 3103 ``` ··· 3145 3145 The import names an identifier (PackageName) to be used for access and an 3146 3146 ImportPath that specifies the package to be imported. 3147 3147 3148 - ``` 3148 + ```ebnf 3149 3149 ImportDecl = "import" ( ImportSpec | "(" { ImportSpec "," } ")" ) . 3150 3150 ImportSpec = [ PackageName ] ImportPath . 3151 3151 ImportLocation = { unicode_value } .