It's UWAweek 47

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 828 articles.
Currently 77 other people reading this forum.


 UWA week 38 (2nd semester, week 8) ↓
SVG not supported

Login to reply

👍?
helpful
5:32am Mon 16th Sep, Joshua N.

"Samay Gupta" <23*6*5*8@s*u*e*t*u*a*e*u*a*> wrote:
> ml language rule #7 states that "variables do not need to be defined before being used in an expression", is the line number 3 in following ml code legit ml expression/statement? > > x <-5 > print x > y > print y
This is invalid syntax.
>program: > ( program-item )*
A program is made up of zero or more program items.
>program-item: > statement > | function identifier ( identifier )* > ←–tab–→ statement1 > ←–tab–→ statement2 > ....
A program item is either a statement or a function, a function can have zero or more identifiers.
>statement: > identifier "<-" expression > | print expression > | return expression > | functioncall
A statement is either an assignment or a print statement or a return statement or a function call (note there is no expression on their own here).
>expression: > term [ ("+" | "-") expression ]
An expression is a term joined with zero or one expressions with either a plus or a minus (expression is called recursively so this can be infinitely long)
>term: > factor [ ("*" | "/") term ]
A term is a factor joined with zero or one terms with either multiplication or division (also recursive so can be infinitely long).
>factor: > realconstant > | identifier > | functioncall > | "(" expression ")"
A factor is a real constant or identifier or function call or expression surrounded by brackets.
>functioncall: > identifier "(" [ expression ( "," expression )* ] ")"
A function call is an identifier followed by two brackets, inside of which can be zero or one expressions followed by zero or more expressions with a comma between them.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy