4223
|
1 === THE PLOKI LANGUAGE: SYNTAX ===
|
|
2
|
|
3
|
|
4 GENERAL STRUCTURE:
|
|
5
|
|
6 A ploki program consists of a (possibly empty) sequence of ordinary lines or
|
|
7 include directives.
|
|
8
|
|
9 An include directive is either absolute or relative. An absolute include
|
|
10 directive is optional whitespace, followed by "INSERT DA", followed by one
|
|
11 or more non-whitespace characters, followed by "HERE", followed by optional
|
|
12 whitespace. A relative include directive is optional whitespace, followed by
|
|
13 "INSERT", followed by optional whitespace, followed by one or more
|
|
14 non-whitespace characters, followed by "HERE", followed by optional
|
|
15 whitespace.
|
|
16
|
|
17 An ordinary line consists of optional whitespace, a label, and stuff.
|
|
18
|
|
19 Stuff consists of an instruction and the rest of the line. Any "??/\n"
|
|
20 sequence (that's four characters: ?, ?, / and newline) in stuff is ignored
|
|
21 unless the instruction is REM.
|
|
22 Example:
|
|
23 WUNT "foo??/
|
|
24 bar"
|
|
25 is equivalent to
|
|
26 WUNT "foobar"
|
|
27 .
|
|
28
|
|
29 There are two types of labels, static and dynamic.
|
|
30 * A static label consists of the three letters "FOR", whitespace and a
|
|
31 non-empty sequence of non-whitespace characters which hasn't been defined
|
|
32 as a static label yet, followed by optional whitespace.
|
|
33 * A dynamic label consists of a possibly empty sequence of digits, followed
|
|
34 by optional whitespace.
|
|
35
|
|
36
|
|
37 INSTRUCTIONS:
|
|
38
|
|
39 These are the available instructions (in no particular order):
|
|
40
|
|
41 * "#!":
|
|
42 A comment. The rest of the line is ignored.
|
|
43
|
|
44 * "REM":
|
|
45 A comment. The rest of the line is ignored but scanned for "REM" ...
|
|
46 "\n" pairs. In other words, REM comments may nest.
|
|
47
|
|
48 * "LET", "LEET":
|
|
49 Assignment. The rest of the line is an optional lvalue, followed by an
|
|
50 expression.
|
|
51
|
|
52 * "WUNT", "SET":
|
|
53 Output. The rest of the line is an optional value, followed by an
|
|
54 expression.
|
|
55
|
|
56 * "IF":
|
|
57 Conditional jump. The rest of the line starts with an expression.
|
|
58
|
|
59 * "ELSE":
|
|
60 Jump. The rest of the line is ignored.
|
|
61
|
|
62 * "FI", "END IF":
|
|
63 Jump target. The rest of the line is ignored.
|
|
64
|
|
65 * "#":
|
|
66 System call. The rest of the line starts with an expression.
|
|
67
|
|
68 * "GOTO", "GOFOR":
|
|
69 Computed jump. The rest of the line starts with an expression.
|
|
70
|
|
71 * "NEXT":
|
|
72 Static jump. The rest of the line must start with the name of a static
|
|
73 label.
|
|
74
|
|
75 * "ANRUF":
|
|
76 Computed call. The rest of the line starts with an expression.
|
|
77
|
|
78 * "ABRUF":
|
|
79 Computed call. The rest of the line is a value, followed by an
|
|
80 expression.
|
|
81
|
|
82 * "END":
|
|
83 Exit. The rest of the line starts with an expression.
|
|
84
|
|
85 * "KTHX":
|
|
86 Return. The rest of the line starts with an expression.
|
|
87
|
|
88 * "CLAUDS":
|
|
89 Close. The rest of the line starts with an expression.
|
|
90
|
|
91 * "FLUSH":
|
|
92 Flush. The rest of the line starts with an expression.
|
|
93
|
|
94 * "RESET":
|
|
95 Clear error/eof flags. The rest of the line starts with an expression.
|
|
96
|
|
97 * "IACS":
|
|
98 Throw. The rest of the line starts with an expression.
|
|
99
|
|
100 * Anything else:
|
|
101 Output. The rest of the line starts with an expression.
|
|
102
|
|
103
|
|
104 EXPRESSION SYNTAX:
|
|
105
|
|
106 An expression either an expression followed by a binary operator and a
|
|
107 value, or a value. A value is either an lvalue or an rvalue. An lvalue is a
|
|
108 plain variable or a hash variable. An rvalue is a special symbol, a
|
|
109 constructor, a unary operator followed by a value, a binary operator
|
|
110 followed by a value, or a "(", followed by an expression, optionally
|
|
111 followed by ")". A plain variable is an identifier; a hash variable is an
|
|
112 identifier, immediately followed by "(", an expression and an optional ")".
|
|
113 An identifier is a non-empty sequence of "a" .. "z", "A" .. "Z", "$".
|
|
114
|
|
115 Special symbols: \<DIGITS> (where <DIGITS> is a non-empty sequence of
|
|
116 digits), \!, \?, \_, \@, \ARG, \AUSG, \EING, \E, \FEHL, \PI, \, (the empty
|
|
117 string).
|
|
118
|
|
119 A constructor is
|
|
120 - a floating point number as recognized by strtod() -OR-
|
|
121 - a string starting with '"', followed by a 0 or more of the following:
|
|
122 "\V" followed by a value, or "\" followed by a non-newline character, or a
|
|
123 non-'"' character;
|
|
124 optionally terminated by '"' -OR-
|
|
125 - a list starting with "#<", followed by 0 or more values, optionally
|
|
126 terminated by "#>".
|
|
127
|
|
128 Unary operators: \ARG:, \ENV, \L, \Q, \R, \U, @-, @+, @ABS, @ACOS, @APERS,
|
|
129 @ASIN, @ATAN, @ATAN2, @CHR, @COS, @DEF-P, @EDD-P, @ENV, @ERR-P, @EVAL, @GET,
|
|
130 @INT, @IO-P, @LAPERS, @LEGS, @LENGTH, @LG, @LN, @NEG, @NOT, @NUM, @ORD,
|
|
131 @OMFG, @REMOVE, @RENAEM, @REVERSE, @SAG, @SAPERS, @SIN, @SQRT, @STR, @SUCH,
|
|
132 @TAN, @TYPE OF, @<LABEL> (where <LABEL> is the name of a static label), @.
|
|
133
|
|
134 Binary operators (separated by spaces):
|
|
135 + - * / % ^ _ < [ { > ] } = ! : ; & | ~ ` ' . , ?o~
|
|
136
|
|
137 # vi: set tw=76 et:
|