Definitions

Prolog Example

  1. brunch (baconbutter). Bacon & Butter is a brunch place.
  2. pub (devere). De Vere is an Irish pub.
  3. brunch (devere). De Vere is a brunch place.
  4. davis (devere). De Vere is in Davis.
  5. sacramento (baconbutter). Bacon & Butter is in Sacramento.
  1. mimosa (X): - brunch (X). Every brunch place has mimosa on their menu.
  2. irishcoffee (X): - davis (X). Every place in Davis has Irish coffee on their menu.
  1. ?- mimosa (X), davis (X). Which place has mimosa and is in Davis?
  2. ?- irishcoffee (X), sacramento (X). Which place has Irish coffee and is in Sacramento.


Recursive Descent Parser

BNF Grammar:
EXP ::= EXP+TERM | EXP-TERM | TERM
TERM ::= TERMFACTOR | TERM/FACTOR | FACTOR
FACTOR ::- (EXP) | DIGIT
DIGIT ::= 0 | 1 | 2 | 3

Valid Strings:
1+2+3+0$
3+2
3/2$
(0+2)(((0+3)-2)/2)$
(((1+3)
2)-3)$

Invalid Strings:
((12)/3$
2
$
(1+a)$
1+1

Enter string using the numbers 0 to 3, the symbols +, -, *, /, (,), and end with $.

Input String:


For Recursive Descent Parser, I use Javascript. I thought doing it in Javascript might be easier than PHP as I am familiar with Java. It takes a while to get familiar with Javascript actually. There are still differences between Java and Javascript. But for sure, having prior knowledge of Java helps with Javascript. I use w3schools to look up syntax for both Javascript and HTML for this website. After completing this assignment, I am still not sufficient with Javascript and HTML. Yet, in my opinion, Javascript and HTML both are well-known languages that are easy to learn and very useful to have on resume.

References

Scanning and Parsing
Syntax and Semantics
An Introduction to Formal Languages and Automata
HTML and Javascript