Post by naripeddy_333I need complete grammar for LOGO programming language.If anyone knows
abt this..please help me out.
In Logo everything is a procedure call. A procedure is either a
command, which has an effect, or an operation, which returns a value.
So basically the syntax is
<instruction> ::= <command-name> <expression>* |
( <command-name> <expression>* )
<expression> ::= <operation-name> <expression>* |
<list> | <quoted-word> | <number> |
<variable-ref> | ( <expression> )
<list> ::= [ <list-element>* ]
<quoted-word> ::= " <word>
<list-element>::= <list> | <word>
<word> ::= <string of characters other than space or [ or ]>
<variable-ref>::= : <word>
except that there is also infix arithmetic with + - * / = < > in the
usual way. Wherever it says <expression>* the number of expressions
must match what the called procedure expects.
It'd be hard to do a really helpful BNF, because of that last point.
It would have to include things like
<proc call> ::= <name-of-proc-with-0-default-inputs> |
<name-of-proc-with-1-default-input> <expr> |
<name-of-proc-with-2-default-inputs> <expr> <expr> |
<name-of-proc-with-3-default-inputs> <expr> <expr> <expr> |
... |
( <name-of-proc-that-can-take-0-inputs> ) |
( <name-of-proc-that-can-take-1-input> <expr> ) |
( <name-of-proc-that-can-take-2-inputs> <expr> <expr> ) |
( <name-of-proc-that-can-take-3-inputs> <expr> <expr> <expr> ) |
...
If you just said <proc-name> <expr>* that wouldn't help you parse things like
foo baz 1 2 3 4 5
for which you need to know the arity of foo and baz. And you actually
need two such rules, one for commands and one for operations.
Also, different dialects differ about the precise rules for tokenization,
so the description of <word> above is a lie. I'm afraid I know of no
published bnf, even for specific dialects.
Logo does have one special form, TO, which is used to define
procedures.
You might want to look at
ftp://ftp.cs.berkeley.edu/pub/ucblogo/usermanual
for the Berkeley Logo reference manual, which gives examples.