-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path2-identifier-syntax.tex
64 lines (46 loc) · 5.03 KB
/
2-identifier-syntax.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
\definesection{Identifier Syntax}
In order to concisely specify \gpl{identifier} we use a special syntax, of which the full grammar and semantics are reflected here using BNF notation. \\
\begin{tabular}{lcl}
\definesyntax{rule} &::=& ``\inline$($''? (\syntax{matcher} \syntax{quantifier}?)+ ``\inline$)$ ''? \\
\definesyntax{matcher} &::=& \multilinecell{\syntax{rule} | \syntax{string} | \syntax{some-characters} \\
| \syntax{any-character} | \syntax{not} | \syntax{either} | \syntax{binding} \\
| \syntax{binding-reference} | \syntax{identifier-reference}} \\
\definesyntax{string} &::=& \syntax{character}+ \\
\definesyntax{char-class} &::=& ``\inline$~$'' \syntax{character} \\
\definesyntax{some-characters} &::=& ``\inline$[$'' \syntax{character}+ ``\inline$]$'' \\
\definesyntax{any-character} &::=& ``\inline$.$'' \\
\definesyntax{not} &::=& ``\inline$!$'' \syntax{matcher} \\
\definesyntax{either} &::=& \syntax{rule} ``\inline$|$'' \syntax{rule}\\
\definesyntax{binding} &::=& ``\inline$<$'' \syntax{name} ``\inline$ $'' \syntax{rule} ``\inline$>$'' \\
\definesyntax{binding-reference} &::=& ``\inline$<$'' \syntax{name} ``\inline$>$'' \\
\definesyntax{identifier-reference} &::=& ``\inline${$'' \syntax{name} ``\inline$}$'' \\
\definesyntax{quantifier} &::=& \syntax{one-or-more} | \syntax{none-or-more} | \syntax{one-or-none} \\
\definesyntax{one-or-more} &::=& \syntax{rule} ``\inline$+$'' \\
\definesyntax{none-or-more} &::=& \syntax{rule} ``\inline$*$'' \\
\definesyntax{one-or-none} &::=& \syntax{rule} ``\inline$?$'' \\
\definesyntax{name} &---& Some \g{alphanumeric} \g{string} to identify the text matched by the \syntax{rule}. \\
\definesyntax{character} &---& A \g{character}. \\
\end{tabular} \\
{\setlength{\parindent}{0cm}
Appearing within the ``'' quotes are \gpl{character} to be found in the \g{identifier specifier}. \\
If a backslash appears anywhere within the \g{identifier specifier}, it is ignored and the \g{character} immediately after it is taken literally without being interpreted as one of the \gpl{character} in the syntax rules and without being interpreted using this backslash rule. Thus two backslashes immediately after one another are interpreted as a single, literal backslash \g{character}. \\
In order for a \syntax{rule} to \g{match}, the \syntax{quantifier} supplied with the \syntax{matcher} must match. If no \syntax{quantifier} is included in a \syntax{rule}, the \syntax{rule} \glink{match}{matches} if the \syntax{matcher} \glink{match}{matches} exactly once. \\
In order for a \syntax{string} to \g{match}, the exact sequence of \gpl{character} must be found. \\
In order for a \syntax{char-class} to \g{match}, a \g{character} specified by the \g{character class} associated with the given \syntax{character} must be found. The following classes are specified: \inline$a$ for \g{alphabetic}, \inline$n$ for \g{numeric}, \inline$_$ for \g{whitespace}, and \inline$w$ for \g{alphanumeric}. \\
In order for \syntax{some-characters} to \g{match}, one of the \gpl{character} must be found. \\
In order for \syntax{any-character} to \g{match}, a single \g{character} must be found, but it matters not which \g{character} it is. \\
In order for \syntax{not} to \g{match}, the following \syntax{matcher} must not \g{match}. \\
In order for \syntax{either} to \g{match}, either the \syntax{rule} left to it, or the \syntax{rule} right to it must \g{match}. \\
In order for \syntax{one-or-more} to \g{match}, the \syntax{rule} must be \glink{match}{matched} at least once, but may be \glink{match}{matched} an arbitrary number of times immediately after each other. The \syntax{rule} is only repeatedly \glink{match}{matched} until the \syntax{rule} immediately after the \syntax{one-or-more} is \glink{match}{matched}. \\
In order for \syntax{none-or-more} to \g{match}, the \syntax{rule} does not have to be \glink{match}{matched} at all, but may be \glink{match}{matched} an arbitrary number of times immediately after each other. The \syntax{rule} is only repeatedly \glink{match}{matched} until the \syntax{rule} immediately after the \syntax{none-or-more} is \glink{match}{matched}. \\
In order for \syntax{one-or-none} to \g{match}, the \syntax{rule} does not have to be \glink{match}{matched} at all, but if it is, it is only \glink{match}{matched} exactly once. \\
In order for a \syntax{binding} to \g{match}, the \syntax{rule} contained must \g{match}. The specific \g{string} \glink{match}{matched} by the \syntax{rule} is then associated with the \syntax{name} of the \syntax{binding}. \\
In order for an \syntax{identifier-reference} to \g{match}, the \g{identifier} corresponding to the \syntax{name} must \g{match}. The effect is as if the according \g{identifier specifier} was used in place of the \syntax{identifier-reference}.\\
In order for a \syntax{binding-reference} to \g{match}, the exact \g{string} associated with the \syntax{name} of the \syntax{binding} must be found.
}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "markless"
%%% TeX-engine: luatex
%%% TeX-command-extra-options: "-shell-escape"
%%% End: