Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs-236:datalog-parser [2017/10/09 18:32]
brob144 [Examples]
cs-236:datalog-parser [2018/09/25 10:46]
pdiddy [FAQ]
Line 210: Line 210:
  
 Rules: Rules:
-  HasSameAddress(X,​Y) :- snap(A,​X,​B,​C),​snap(D,​Y,​B,​E).+  HasSameAddress(X,​Y) :- snap(A,​X,​B,​C),​snap(D,​Y,​B,​(E+C)).
  
 #comment #comment
Line 228: Line 228:
   snap('​33333','​Snoopy','​12 Apple','​555-1234'​).   snap('​33333','​Snoopy','​12 Apple','​555-1234'​).
 Rules(1): Rules(1):
-  HasSameAddress(X,​Y) :- snap(A,​X,​B,​C),​snap(D,​Y,​B,​E).+  HasSameAddress(X,​Y) :- snap(A,​X,​B,​C),​snap(D,​Y,​B,​(E+C)).
 Queries(1): Queries(1):
   HasSameAddress('​Snoopy',​Who)?​   HasSameAddress('​Snoopy',​Who)?​
Line 269: Line 269:
  
 The grammar is in the [http://​www.antlr.org ANTLR] format. [http://​www.antlr.org ANTLR] is a tool that takes a grammar specification like the one on this webpage and automatically turns it into a lexical analyzer and parser for several different output languages. The key changes are this: the '​|'​ character is used to separate different rules for a given non-terminal rather than a new line (much like BNF); non-terminals are lowercase; terminals are upper-case; if something is not separated by the '​|'​ character, then it is part of the same rule (see the first rule for for the datalog program example); and the first rule is the start rule. The grammar is in the [http://​www.antlr.org ANTLR] format. [http://​www.antlr.org ANTLR] is a tool that takes a grammar specification like the one on this webpage and automatically turns it into a lexical analyzer and parser for several different output languages. The key changes are this: the '​|'​ character is used to separate different rules for a given non-terminal rather than a new line (much like BNF); non-terminals are lowercase; terminals are upper-case; if something is not separated by the '​|'​ character, then it is part of the same rule (see the first rule for for the datalog program example); and the first rule is the start rule.
- +
 '''​What do I have to change in my Lexical Analyzer?'''​ '''​What do I have to change in my Lexical Analyzer?'''​
  
cs-236/datalog-parser.txt ยท Last modified: 2018/09/25 10:46 by pdiddy
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0