29.12.2013 Views

Prolog A Tutorial Introduction - Courses

Prolog A Tutorial Introduction - Courses

Prolog A Tutorial Introduction - Courses

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

::= NUMBER |<br />

IDENT |<br />

IDENT <br />

parseFnExp(Sin,Sout) :-<br />

eat(number,Sin,Sout).<br />

parseFnExp(Sin,Sout) :-<br />

eat(ident(_),Sin,Sout).<br />

parseFnExp(Sin,Sout) :-<br />

eat(ident(_),Sin,R),<br />

parseTermList(R,Sout).<br />

Problem 13<br />

Now, using the techniques described above, implement a set of parse predicates for the FP grammar<br />

which follows. Be sure to test it out when you are done.<br />

<br />

::= PERIOD<br />

::= |<br />

SCOLON <br />

<br />

::= IDENT ASSIGN <br />

::= |<br />

let in <br />

::= IDENT |<br />

IDENT <br />

::= NUMBER |<br />

IDENT |<br />

|<br />

<br />

::= if then [] endif<br />

<br />

<br />

<br />

<br />

<br />

::= else <br />

::= <br />

::= LT | LE | GT | GE | EQ | NE<br />

::= <br />

::= IDENT | ADD | SUBT | MULT | DIV | MOD<br />

::= |<br />

<br />

::= NUMBER |<br />

IDENT |<br />

LP RP<br />

CSCI 208 26 <strong>Prolog</strong> <strong>Tutorial</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!