in reply to What is the difference between a Statement and an Expression?

Lets look at a little grammar for a simple compiler perhaps this will help.
expression -> expression + term | expression - term | term statement-> id = expression | if expression then statement | while expression do statement

Notice that in my language grammar (taken directly out of he 'Red Dragon' Compiler Book, Aho, Sethi, Ullman). Statements always begin with either a identifier or a keyword.

$x = 1+1; <--- statement starts with an identifier x followed by an expression 1+1 </code>

mitd-Made in the Dark
'My favourite colour appears to be grey.'

Replies are listed 'Best First'.
Re^2: What is the difference between a Statement and an Expression?
by JavaFan (Canon) on Mar 02, 2012 at 01:15 UTC
    Statements always begin with either a identifier or a keyword.
    That's not true for Perl:
    1 == $variable or next;
    It's also not true for C.
    3;
    is a valid, although useless, statement.