Fixed English mechanics: grammar, punctuation, and wording

This commit is contained in:
Pound_Hash 2022-04-11 14:00:43 -07:00
parent b2c6bc4690
commit 56287daac0

View File

@ -1,26 +1,24 @@
= Command Parsing = Command Parsing
Kakoune commands, either loaded from a script, or written in the command Kakoune commands, either loaded from a script or written in the command prompt, are parsed according to the following rules:
prompt are parsed according to the following rules:
== Basic parsing == Basic parsing
- Commands are separated by `;` or end of lines - Commands are delimited by a `;` or an end of line
- Words (command names and parameters) are separated by whitespaces - Words (command names and parameters) are delimited by whitespaces
== Quoted Strings == Quoted Strings
If a word starts with `'`, `"` or `%X` with `X` a non nestable If a word starts with `'`, `"`, or `%X` with `X` a non-nestable punctuation character (see below for nestable characters),
punctuation character it is parsed as a quoted string whose delimiter is, it is parsed as a quoted string whose delimiter is, respectively, `'`, `"`, or `X`.
respectively, `'`, `"` or `X`.
A quoted string contains every character (including whitespaces) until A quoted string contains every character (including whitespaces). Doubling a closing delimiter escapes it.
its closing delimiter. If its closing delimiter is doubled, then it is Thus, for example, entering two closing delimiting characters at the end of a quoted string will render one of the characters literally;
considered to be part of the string content as a single delimiter. that is, it will be considered as part of the quoted string's content.
Inside double quotes, `%`-strings are processed unless the `%` is escaped by Inside double quotes, `%`-strings are processed unless the `%` is escaped by doubling it.
doubling it. Double quotes inside these nested strings must still be escaped. Double quotes inside these nested strings must still be escaped.
No other escaping takes place in quoted strings. No other escaping takes place in quoted strings.
@ -42,17 +40,11 @@ No other escaping takes place in quoted strings.
== Balanced Strings == Balanced Strings
If a word starts with `%X` with `X` a nestable punctuation character (one If a word starts with `%X` with `X` a nestable punctuation character (one of `(`, `[`, `{` and `<`),
of `(`, `[`, `{` and `<`), it is parsed as a balanced string whose closing it is parsed as a balanced string
delimiter is the matching character of its opening delimiter (respectively whose closing delimiter matches that of its opening delimiter (respectively `)`, `]`, `}` and `>`).
`)`, `]`, `}` and `>`).
A balanced string contains every character (including whitespaces) until Characters may be escaped in the same manner as those for quoted strings.
a closing delimiter is found, and opening and closing delimiters are
balanced inside the string (each opening delimiter appearing inside the
string have been closed by a matching closing delimiter).
No other escaping takes place in balanced strings.
=== Balanced Strings Examples === Balanced Strings Examples
@ -66,23 +58,22 @@ No other escaping takes place in balanced strings.
== Non Quoted words == Non Quoted words
Other words are non-quoted. Non-quoted words end either on a whitespaces Other words are non-quoted.
or a `;`. Non-quoted words end either at a whitespace or a `;`.
If they start with `\` followed by `%`, `'` or `"`, then that leading If they start with a `\` followed by a `%`, `'`, or `"`,
`\` is discarded. then that leading `\` escapes those characters and is discarded.
If a whitespace or `;` is preceded by `\`, then the `\` is discarded If a whitespace or `;` is preceded by a `\`,
and the whitespace or `;` becomes part of the word. Any other `\` then the `\` is discarded, and the whitespace or `;` becomes part of the word.
is treated as a literal `\`. Any other `\` is treated as a literal `\`.
== Typed Expansions == Typed Expansions
Quoted and Balanced strings starting with `%` might have an optional Quoted and Balanced strings starting with `%` might have an optional alphabetic *expansion type* between the `%` and their delimiter
alphabetic *expansion type* between the `%` and their delimiter (which (which is always a punctuation character).
is always a punctuation character). This *expansion type* defines how the This *expansion type* defines how the string's content is going to be expanded.
string content is going to be expanded. Rules for expanding and escaping typed Rules for expanding and escaping expansion types are the same as for `%`-strings.
expansions are the same as for `%`-strings.
- If the *expansion type* is empty, the string content is used verbatim. - If the *expansion type* is empty, the string content is used verbatim.