generated from potassco/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from potassco/nico/user-input-new
Nico/user input new
- Loading branch information
Showing
44 changed files
with
2,026 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
set color[0] = "Yellow" | ||
// add basket | ||
add 2 carrier[0].bag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
value(X,V) :- user_value(X,V). | ||
include(X) :- user_include(X). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,6 @@ | |
#defined number/2. | ||
|
||
#defined function/3. | ||
|
||
#defined user_include/1. | ||
#defined user_value/2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
value(X,V) :- user_value(X,V), type(X,T), discrete(T). | ||
&in{V..V} =: X :- user_value(X,V), type(X,T), integer(T). | ||
include(X) :- user_include(X). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ | |
|
||
#defined coom_function/4. | ||
#defined coom_imply/3. | ||
|
||
#defined coom_user_include/1. | ||
#defined coom_user_value/2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
% Check that variables exist | ||
unsat("not exists",X) :- user_value(X,_), not type(X,_). | ||
unsat("not exists",X) :- user_include(X), not type(X,_). | ||
|
||
% Check variable type | ||
unsat("not part",X) :- user_include(X), type(X,T), not part(T). | ||
unsat("not attribute",X) :- user_value(X,V), type(X,T), #false : discrete(T); #false : integer(T). | ||
|
||
% Check valid domain | ||
unsat("outside domain",(X,V)) :- user_value(X,V), type(X,T), discrete(T), not domain(T,V). | ||
unsat("outside domain",(X,V)) :- user_value(X,V), type(X,T), integer(T), range(T,Min,Max), V < Min. | ||
unsat("outside domain",(X,V)) :- user_value(X,V), type(X,T), integer(T), range(T,Min,Max), V > Max. | ||
% Check max cardinality not exceeded | ||
% For now this is covered by line 3 (only max amount of objects is grounded) | ||
|
||
#show unsat/2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
""" | ||
COOM model files | ||
COOM grammar files | ||
""" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
COOM model grammar files | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
grammar Base; | ||
|
||
@parser::header {} | ||
|
||
@parser::members { | ||
def wasNewline(self): | ||
for index in reversed(range(self.getCurrentToken().tokenIndex)): | ||
# stop on default channel | ||
token = self.getTokenStream().get(index) | ||
if token.channel == 0: | ||
break | ||
# if the token is blank and contains newline, we found it | ||
if len(token.text) == 0: | ||
continue | ||
if token.text.startswith("\n") or token.text.startswith("\r"): | ||
return True | ||
return False | ||
} | ||
|
||
floating: | ||
'-'? (FLOATING | INTEGER | '\u221e'); // == infinity symbol | ||
// define path expressions | ||
path: path_item ('.' path_item)*; | ||
path_item: name ('[' path_index ('..' path_index)? ']')?; | ||
path_index: INTEGER | ('last' ('-' INTEGER)?); | ||
|
||
name: NAME; // | FUNCTION | KEYWORD; | ||
stmt_end: ';' | {self.wasNewline()}; | ||
|
||
NAME: (ALPHA ALPHANUMERIC*) | QUOTED_SINGLE | QUOTED_DOUBLE; | ||
|
||
formula_atom: | ||
atom_true = 'true' | ||
| atom_false = 'false' | ||
| atom_num = floating | ||
| atom_path = path; | ||
|
||
fragment ALPHANUMERIC: ALPHA | DIGIT; | ||
fragment ALPHA: | ||
[_a-zA-Z$\u00A2-\u00A5\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD] | ||
; | ||
fragment DIGIT: [0-9]; | ||
|
||
fragment QUOTED_SINGLE: '\'' (ESC | ~['\\\u0000-\u001F])* '\''; | ||
fragment QUOTED_DOUBLE: '"' (ESC | ~["\\\u0000-\u001F])* '"'; | ||
fragment ESC: '\\' (["\\/bfnrt] | UNICODE); | ||
fragment UNICODE: 'u' HEX HEX HEX HEX; | ||
fragment HEX: [0-9a-fA-F]; | ||
INTEGER: DIGIT+; | ||
FLOATING: DIGIT+ ('.' DIGIT+)?; | ||
// skip whitespaces, but get the newlines in a spearate channel | ||
NEWLINE: [\r\n]+ -> channel(HIDDEN); | ||
WHITESPACE: [ \t]+ -> skip; | ||
// allow java-like comments, direct them into the comment channel | ||
COMMENT: '//' ~[\n\r]* ( [\n\r] | EOF) -> channel(HIDDEN); | ||
MULTILINE_COMMENT: | ||
'/*' (MULTILINE_COMMENT | .)*? ('*/' | EOF) -> channel(HIDDEN); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Grammar to define user input (customer product requirements) | ||
*/ | ||
|
||
grammar UserInput; | ||
import Base; | ||
|
||
user_input: (input_block | input_operation)* EOF; | ||
|
||
input_block: 'blockinput' path '{' input_operation* '}'; | ||
|
||
input_operation: set_value | add_instance; | ||
|
||
set_value: op = 'set' path '=' formula_atom; | ||
add_instance: op = 'add' INTEGER? path; |
Oops, something went wrong.