summaryrefslogtreecommitdiff
path: root/prolog
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-05-08 17:28:19 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-05-08 17:28:19 +0200
commitddf271d3070d998e901c6fa3e21464602c9b6359 (patch)
treec88510f9220b33c282eb013d066c4ff545ee7437 /prolog
parent2abd6d93e113886c4fa9d4cdf0c578b5ea11a1fb (diff)
Prolog: support CLP(FD) in parser
Diffstat (limited to 'prolog')
-rw-r--r--prolog/lexer.py9
-rw-r--r--prolog/parser.py16
2 files changed, 23 insertions, 2 deletions
diff --git a/prolog/lexer.py b/prolog/lexer.py
index 7ca67e1..f905a2b 100644
--- a/prolog/lexer.py
+++ b/prolog/lexer.py
@@ -46,6 +46,15 @@ operators = {
r'@=<': 'LEL',
r'@>': 'GTL',
r'@>=': 'GEL',
+ r'#=': 'EQFD',
+ r'#\=': 'NEQFD',
+ r'#<': 'LTFD',
+ r'#=<': 'LEFD',
+ r'#>': 'GTFD',
+ r'#>=': 'GEFD',
+ r'in': 'IN',
+ r'ins': 'INS',
+ r'..': 'THROUGH',
r'+': 'PLUS',
r'-': 'MINUS',
r'*': 'STAR',
diff --git a/prolog/parser.py b/prolog/parser.py
index 19d2da5..4a3f4b5 100644
--- a/prolog/parser.py
+++ b/prolog/parser.py
@@ -24,7 +24,7 @@ precedence = (
('nonassoc', 'FROM'),
('right', 'IMPLIES'),
('right', 'NOT'),
- ('nonassoc', 'EQU', 'NEQU', 'EQ', 'NEQ', 'UNIV', 'IS', 'EQA', 'NEQA', 'LT', 'LE', 'GT', 'GE', 'LTL', 'LEL', 'GTL', 'GEL'),
+ ('nonassoc', 'EQU', 'NEQU', 'EQ', 'NEQ', 'UNIV', 'IS', 'EQA', 'NEQA', 'LT', 'LE', 'GT', 'GE', 'LTL', 'LEL', 'GTL', 'GEL', 'IN', 'INS', 'THROUGH', 'EQFD', 'NEQFD', 'LTFD', 'LEFD', 'GTFD', 'GEFD'),
('left', 'PLUS', 'MINUS'),
('left', 'STAR', 'DIV', 'IDIV', 'MOD'),
('nonassoc', 'POW'),
@@ -123,16 +123,28 @@ def p_term_binary(p):
| term NEQ term
| term UNIV term
| term IS term
+
| term EQA term
| term NEQA term
| term LT term
| term LE term
| term GT term
| term GE term
+
| term LTL term
| term LEL term
| term GTL term
- | term GEL term'''
+ | term GEL term
+
+ | term THROUGH term
+ | term IN term
+ | term INS term
+ | term EQFD term
+ | term NEQFD term
+ | term LTFD term
+ | term LEFD term
+ | term GTFD term
+ | term GEFD term'''
p[0] = Tree('term', [p[1], make_token(p, 2), p[3]])
def p_term_unary(p):
'''term : NOT term