Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PFDL code #60

Merged
merged 56 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
59bd720
Do not generate callbacks if used in extension
maxhoerstr Dec 6, 2022
6e261eb
Save petri net as dot file in extension
maxhoerstr Dec 13, 2022
673467f
Remove unnecessary new line character
maxhoerstr Dec 13, 2022
2298d3e
Add group ids for places in petri net
maxhoerstr Dec 13, 2022
85f43f2
Save group ids in transitions
maxhoerstr Jan 17, 2023
5e472fd
Add id of parent group
maxhoerstr Jan 17, 2023
95ecbb2
Fix missing args in method calls
maxhoerstr Jan 17, 2023
8b62e42
Create a tree with group ids while generating
maxhoerstr Jan 17, 2023
4c33691
Save petri net tree into media folder
maxhoerstr Feb 8, 2023
e74f9fe
Remove now unused parent group ids
maxhoerstr Feb 9, 2023
d8c99a0
Save petri net tree in dot file
maxhoerstr Feb 28, 2023
297abdd
Fix drawing of petri net
maxhoerstr Mar 7, 2023
d4eeaf0
Add identifier in dot file for call tree
maxhoerstr Mar 7, 2023
53d22e8
Remove comment in dot file
maxhoerstr Mar 8, 2023
24cf7b3
Enforce passing of file name for extension
maxhoerstr Mar 9, 2023
eb8ad6c
Fix bugs
maxhoerstr Mar 9, 2023
d3186fa
Cluster petri net components
maxhoerstr Mar 24, 2023
60a8318
Draw dot file every time
maxhoerstr Mar 24, 2023
f2fdb89
Fix minor issues
maxhoerstr Apr 6, 2023
8106ef9
Minor changes
maxhoerstr Apr 11, 2023
91129fd
Small fixes
maxhoerstr Apr 13, 2023
eb3c641
Save order specific petri net image and dot file
maxhoerstr Apr 13, 2023
9a00ebc
Use scheduler id for logging
maxhoerstr Apr 13, 2023
325edb7
Remove saving of tokens
maxhoerstr Apr 13, 2023
0fdfd3a
Use correct transition list
maxhoerstr Apr 15, 2023
663c7ad
Cast loop limit to int before using it
maxhoerstr Apr 16, 2023
eeda72e
Add correct casting
maxhoerstr Apr 16, 2023
c126d34
Allow integers in counting loop limits
maxhoerstr Jun 14, 2023
72da9bb
Support integer loop limits in scheduler
maxhoerstr Jun 14, 2023
df88d25
Move content of init into separate functions
maxhoerstr Jun 14, 2023
e0dc44a
Allow other statements to be processed
maxhoerstr Jun 14, 2023
359b741
Check if task and service are in loop in callbacks
maxhoerstr Nov 21, 2023
8c7003a
Add option to pass the PFDL program as a string
OliverStolzBO Dec 5, 2023
3faa540
Rename id to uuid for consistency
OliverStolzBO Jan 9, 2024
8059056
Add helper method to cast datatypes from string
OliverStolzBO Jan 12, 2024
e48e0be
Enable empty comments in PFDL programs
OliverStolzBO Jan 17, 2024
68809a0
Move helper method into semantic error checker
OliverStolzBO Feb 16, 2024
02a070c
Add unit test for integer loop limits
maxhoerstr Mar 19, 2024
674b648
Rename dict key for consistency
OliverStolzBO Apr 10, 2024
61c72ef
Edit test file to avoid naming conflicts
OliverStolzBO Apr 10, 2024
5bd0be9
Split method
OliverStolzBO Apr 10, 2024
233ab33
Correct the clustering of nodes
maxhoerstr Apr 12, 2024
73f0fb8
Update generator
OliverStolzBO Apr 15, 2024
61e57a9
Extend grammar by variable type representation
OliverStolzBO Apr 15, 2024
a7e04a1
Fix old clustering code
maxhoerstr Apr 26, 2024
ab57358
Allow negative numbers
maxhoerstr Apr 30, 2024
8498513
Update generated lexer file
maxhoerstr Apr 30, 2024
c737873
Add better documentation for petri net logic
maxhoerstr Apr 30, 2024
ea838f5
Enable flexible starting task names for plugins
OliverStolzBO Aug 19, 2024
54d5757
Merge branch 'main' into refactoring
maxhoerstr Aug 20, 2024
83bfdfe
Update transition ids that were broken after merge
maxhoerstr Aug 20, 2024
0c467fc
Remove more code that was introduced due to the merge
maxhoerstr Aug 20, 2024
9a49858
Add constants that were lost due to merge
maxhoerstr Aug 21, 2024
f180401
Check if there is only a single task call in parallel loop
maxhoerstr Aug 21, 2024
e6a9bca
Incorporate PR feedback
maxhoerstr Aug 23, 2024
b3fa710
Rename test program variables
OliverStolzBO Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions pfdl_grammar/PFDLLexer.g4
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
lexer grammar PFDLLexer;

// DenterHelper for generating INDENT AND DEDENT tokens to realize
// a python-like grammar with Indentations
// DenterHelper for generating INDENT AND DEDENT tokens to realize a python-like grammar with
// Indentations

tokens { INDENT, DEDENT }
tokens {
INDENT,
DEDENT
}

@lexer::header{
@lexer::header {
from antlr_denter.DenterHelper import DenterHelper
from PFDLParser import PFDLParser
}
Expand Down Expand Up @@ -56,7 +59,7 @@ QUOTE: '"';
ARRAY_LEFT: '[';
ARRAY_RIGHT: ']';

COMMENT : '#' ~[\n]+ -> skip;
COMMENT: '#' ~[\n]* -> skip;
WHITESPACE: [ \t]+ -> skip;
NL: ('\r'? '\n' ' '*);

Expand All @@ -76,48 +79,39 @@ SLASH: '/';
MINUS: '-';
PLUS: '+';


INTEGER: [0-9]+;
FLOAT: INTEGER '.'INTEGER;
FLOAT: INTEGER '.' INTEGER;

STRING: '"' ('\\"'|.)*? '"';
STRING: '"' ('\\"' | .)*? '"';
STARTS_WITH_LOWER_C_STR: [a-z][a-zA-Z0-9_]*;
STARTS_WITH_UPPER_C_STR: [A-Z][a-zA-Z0-9_]*;

// JSON Grammar
mode JSON;

JSON_STRING: '"' ('\\"'|.)*? '"';
JSON_STRING: '"' ('\\"' | .)*? '"';
JSON_TRUE: 'true';
JSON_FALSE: 'false';

JSON_COLON: ':';
JSON_QUOTE: '"';

JSON_COMMENT : '#' ~[\n]+ -> skip;
JSON_COMMENT: '#' ~[\n]+ -> skip;

JSON_ARRAY_LEFT: '[';
JSON_ARRAY_RIGHT: ']';

JSON_COMMA: ',';

NUMBER
: '-'? INT ('.' [0-9] +)? EXP?
;
NUMBER: '-'? INT ('.' [0-9]+)? EXP?;

fragment INT
: '0' | [1-9] [0-9]*
;
fragment INT: '0' | [1-9] [0-9]*;

// no leading zeros

fragment EXP
: [Ee] [+\-]? INT
;
fragment EXP: [Ee] [+\-]? INT;

WS
: [ \t\n\r] + -> skip
;
WS: [ \t\n\r]+ -> skip;

JSON_OPEN_2: '{' -> pushMode(JSON);
JSON_CLOSE: '}' -> popMode;
JSON_CLOSE: '}' -> popMode;
33 changes: 16 additions & 17 deletions pfdl_grammar/PFDLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ while_loop:
LOOP WHILE expression INDENT statement+ DEDENT;

counting_loop:
PARALLEL? LOOP STARTS_WITH_LOWER_C_STR TO attribute_access INDENT statement+ DEDENT;
PARALLEL? LOOP STARTS_WITH_LOWER_C_STR TO (attribute_access | INTEGER) INDENT statement+ DEDENT;

condition:
CONDITION INDENT expression NL+ DEDENT condition_passed condition_failed?;
Expand All @@ -60,15 +60,16 @@ condition_failed:
FAILED INDENT statement+ DEDENT;

parameter:
STARTS_WITH_LOWER_C_STR
| attribute_access;
STARTS_WITH_LOWER_C_STR | attribute_access;

struct_initialization:
STARTS_WITH_UPPER_C_STR INDENT json_object NL+ DEDENT
| STARTS_WITH_UPPER_C_STR NL* json_object NL*;

variable_definition:
STARTS_WITH_LOWER_C_STR COLON primitive array?;
STARTS_WITH_LOWER_C_STR COLON variable_type;

variable_type: primitive array?;

primitive:
NUMBER_P
Expand All @@ -82,9 +83,7 @@ attribute_access:
array:
ARRAY_LEFT (INTEGER | STARTS_WITH_LOWER_C_STR)? ARRAY_RIGHT;

number:
INTEGER
| FLOAT;
number: MINUS? (INTEGER | FLOAT);

value:
TRUE
Expand Down Expand Up @@ -128,13 +127,13 @@ json_open_bracket:
JSON_OPEN | JSON_OPEN_2;

json_value:
JSON_STRING
| JSON_TRUE
| JSON_FALSE
| NUMBER
| json_object
| json_array;

json_array
: JSON_ARRAY_LEFT json_value (JSON_COMMA json_value)* JSON_ARRAY_RIGHT
| JSON_ARRAY_LEFT JSON_ARRAY_RIGHT;
JSON_STRING
| JSON_TRUE
| JSON_FALSE
| NUMBER
| json_object
| json_array;

json_array:
JSON_ARRAY_LEFT json_value (JSON_COMMA json_value)* JSON_ARRAY_RIGHT
| JSON_ARRAY_LEFT JSON_ARRAY_RIGHT;
10 changes: 9 additions & 1 deletion pfdl_scheduler/model/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ class Process:
Attributes:
structs: A dict for mapping the Struct names to the Struct objects.
task: A dict for mapping the Task names to the Task objects.
start_task_name: the name of the start task of the PFDL program (typically "productionTask").
"""

def __init__(self, structs: Dict[str, Struct] = None, tasks: Dict[str, Task] = None) -> None:
def __init__(
self,
structs: Dict[str, Struct] = None,
tasks: Dict[str, Task] = None,
start_task_name: str = "productionTask",
) -> None:
"""Initialize the object.

Args:
structs: A dict for mapping the Struct names to the Struct objects.
tasks: A dict for mapping the Task names to the Task objects.
start_task_name: the name of the start task of the PFDL program (typically "productionTask").
"""
if structs:
self.structs: Dict[str, Struct] = structs
Expand All @@ -42,3 +49,4 @@ def __init__(self, structs: Dict[str, Struct] = None, tasks: Dict[str, Task] = N
self.tasks: Dict[str, Task] = tasks
else:
self.tasks: Dict[str, Task] = {}
self.start_task_name = start_task_name
Loading
Loading