From bd19d15a85b8e4cfb466513a04861f08ac9f9932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Thu, 28 Sep 2023 11:18:10 +0200 Subject: [PATCH 1/3] [spec] Remove highlighting in the lists of keywords. The highlighter does not print all keywords with the same color, which makes sense in actual code snippets, but is confusing in the raw lists of all keywords. --- docs/_spec/01-lexical-syntax.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/_spec/01-lexical-syntax.md b/docs/_spec/01-lexical-syntax.md index a2b5c4c423a9..9ced89228e22 100644 --- a/docs/_spec/01-lexical-syntax.md +++ b/docs/_spec/01-lexical-syntax.md @@ -83,7 +83,7 @@ For this purpose, lower case letters include not only a-z, but also all characte The following are examples of variable identifiers: -> ```scala +> ``` > x maxIndex p2p empty_? > `yield` αρετη _y dot_product_* > __system _MAX_LEN_ @@ -92,7 +92,7 @@ The following are examples of variable identifiers: Some examples of constant identifiers are -> ```scala +> ``` > + Object $reserved Džul ǂnûm > ⅰ_ⅲ Ⅰ_Ⅲ ↁelerious ǃqhàà ʹthatsaletter > ``` @@ -104,7 +104,7 @@ User programs should not define identifiers that contain ‘$’ characters. The following names are reserved words instead of being members of the syntactic class `id` of lexical identifiers. -```scala +``` abstract case catch class def do else enum export extends false final finally for given if implicit import lazy match new @@ -169,14 +169,14 @@ A newline in a Scala source text is treated as the special token “nl” if the The tokens that can terminate a statement are: literals, identifiers and the following delimiters and reserved words: -```scala +``` this null true false return type _ ) ] } ``` The tokens that can begin a statement are all Scala tokens _except_ the following delimiters and reserved words: -```scala +``` catch else extends finally forSome match with yield , . ; : = => <- <: <% >: # [ ) ] } @@ -452,7 +452,7 @@ Characters must not necessarily be printable; newlines or other control characte > > This would produce the string: > -> ```scala +> ``` > the present string > spans three > lines. @@ -469,7 +469,7 @@ Characters must not necessarily be printable; newlines or other control characte > > evaluates to > -> ```scala +> ``` > the present string > spans three > lines. From b4ce68461faa6cc4283d0b557c23665505b5babf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Thu, 28 Sep 2023 11:23:09 +0200 Subject: [PATCH 2/3] [spec] Fix the GitHub URL to edit the spec files. --- docs/_spec/_layouts/default.yml | 2 +- docs/_spec/_layouts/toc.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_spec/_layouts/default.yml b/docs/_spec/_layouts/default.yml index 2589a105dff2..5d597cb5ea96 100644 --- a/docs/_spec/_layouts/default.yml +++ b/docs/_spec/_layouts/default.yml @@ -27,7 +27,7 @@
From 18c8f91d606cddae9642aac233a92ed4cf0ae1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Thu, 28 Sep 2023 11:45:20 +0200 Subject: [PATCH 3/3] [spec] Better align EBNF grammars in the lexical syntax chapter. --- docs/_spec/01-lexical-syntax.md | 39 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/docs/_spec/01-lexical-syntax.md b/docs/_spec/01-lexical-syntax.md index 9ced89228e22..9f7c3ba76a24 100644 --- a/docs/_spec/01-lexical-syntax.md +++ b/docs/_spec/01-lexical-syntax.md @@ -43,17 +43,17 @@ colon ::= ':' -- with side conditions explained above ## Identifiers ```ebnf -op ::= opchar {opchar} -varid ::= lower idrest -boundvarid ::= varid - | ‘`’ varid ‘`’ -alphaid ::= upper idrest - | varid -plainid ::= alphaid - | op -id ::= plainid - | ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’ -idrest ::= {letter | digit} [‘_’ op] +op ::= opchar {opchar} +varid ::= lower idrest +boundvarid ::= varid + | ‘`’ varid ‘`’ +alphaid ::= upper idrest + | varid +plainid ::= alphaid + | op +id ::= plainid + | ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’ +idrest ::= {letter | digit} [‘_’ op] escapeSeq ::= UnicodeEscape | charEscapeSeq UnicodeEscape ::= ‘\’ ‘u’ {‘u’} hexDigit hexDigit hexDigit hexDigit hexDigit ::= ‘0’ | ... | ‘9’ | ‘A’ | ... | ‘F’ | ‘a’ | ... | ‘f’ @@ -177,9 +177,8 @@ _ ) ] } The tokens that can begin a statement are all Scala tokens _except_ the following delimiters and reserved words: ``` -catch else extends finally forSome match -with yield , . ; : = => <- <: <% ->: # [ ) ] } +catch else extends finally forSome match with yield +, . ; : = => <- <: <% >: # [ ) ] } ``` A `case` token can begin a statement only if followed by a @@ -334,8 +333,7 @@ Literal ::= [‘-’] integerLiteral ### Integer Literals ```ebnf -integerLiteral ::= (decimalNumeral | hexNumeral) - [‘L’ | ‘l’] +integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’] decimalNumeral ::= ‘0’ | digit [{digit | ‘_’} digit] hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit [{hexDigit | ‘_’} hexDigit] ``` @@ -366,11 +364,10 @@ The digits of a numeric literal may be separated by arbitrarily many underscores ### Floating Point Literals ```ebnf -floatingPointLiteral - ::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType] - | decimalNumeral exponentPart [floatType] - | decimalNumeral floatType -exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit [{digit | ‘_’} digit] +floatingPointLiteral ::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType] + | decimalNumeral exponentPart [floatType] + | decimalNumeral floatType +exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit [{digit | ‘_’} digit] ``` Floating point literals are of type `Float` when followed by a floating point type suffix `F` or `f`, and are of type `Double` otherwise.