Download Dpic manual - Electrical and Computer Engineering
Transcript
5.4
\ lines
Both gpic and dpic pass lines beginning with \ to the output but dpic does not automatically
append a % at the end as gpic does.
5.5
for-loop and if bodies
In gpic, a for loop has the form
for variable = expr1 to expr2 [by [*]expr3] do X body X
where X is any character not occurring in body, but { body } is also allowed. In dpic only
the latter is allowed. Similarly, the required form of an if statement for dpic is
if expr then { if-true } [else { if-false }]
The test for termination of the multiplicative form of the for loop is not identical for dpic and
gpic but the effects are identical for positive parameters.
Both gpic and recent versions of dpic allow the loop index variable to be changed within the
loop, so infinite repetition or control of termination by a test are possible.
5.6
End of line
The line end is significant in the pic grammar. However, dpic ignores line ends following then,
{, else, or end of line. Both the CR (octal 015) and NL (octal 012) characters are treated as
line ends.
If the last character of a line is \ (but not within a string), then reading is continued on the
next line. Dpic allows this to occur within keywords or constants. Strings can contain multiple
lines.
The # character begins a comment which ends at the end of the line.
The construction
if condition then { if-true }
else { if-false }
produces an error with all pic interpreters. To avoid this error, write
if condition then { if-true } \
else { if-false }
5.7
Logic
Dpic and gpic give slightly different default precedences to the logical operators !, &&, ||, ==,
!=, >=, <=, <, and >, so judicious use of parentheses may sometimes be in order to guarantee
identical behavior. In addition, put string comparisons in parentheses, e.g.
("text1" == "text2")
21