fprime-gds 4.0.2a3__py3-none-any.whl → 4.0.2a4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. fprime_gds/common/distributor/distributor.py +9 -6
  2. fprime_gds/common/fpy/README.md +190 -42
  3. fprime_gds/common/fpy/SPEC.md +153 -39
  4. fprime_gds/common/fpy/bytecode/assembler.py +62 -0
  5. fprime_gds/common/fpy/bytecode/directives.py +620 -294
  6. fprime_gds/common/fpy/codegen.py +687 -910
  7. fprime_gds/common/fpy/grammar.lark +44 -9
  8. fprime_gds/common/fpy/main.py +27 -4
  9. fprime_gds/common/fpy/model.py +799 -0
  10. fprime_gds/common/fpy/parser.py +29 -34
  11. fprime_gds/common/fpy/test_helpers.py +119 -0
  12. fprime_gds/common/fpy/types.py +563 -0
  13. fprime_gds/executables/cli.py +9 -0
  14. fprime_gds/executables/run_deployment.py +2 -0
  15. fprime_gds/flask/app.py +17 -2
  16. fprime_gds/flask/default_settings.py +1 -0
  17. fprime_gds/flask/static/index.html +7 -4
  18. fprime_gds/flask/static/js/config.js +9 -1
  19. fprime_gds/flask/static/js/vue-support/channel.js +16 -0
  20. fprime_gds/flask/static/js/vue-support/event.js +1 -0
  21. fprime_gds/flask/static/js/vue-support/fp-row.js +25 -1
  22. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/METADATA +1 -1
  23. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/RECORD +28 -24
  24. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/entry_points.txt +2 -1
  25. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/WHEEL +0 -0
  26. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/licenses/LICENSE.txt +0 -0
  27. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/licenses/NOTICE.txt +0 -0
  28. {fprime_gds-4.0.2a3.dist-info → fprime_gds-4.0.2a4.dist-info}/top_level.txt +0 -0
@@ -31,13 +31,36 @@ _expr: _test
31
31
 
32
32
  # logical tests
33
33
  _test: or_test
34
- ?or_test: and_test ("or" and_test)*
35
- ?and_test: not_test_ ("and" not_test_)*
36
- ?not_test_: "not" not_test_ -> not_test
34
+
35
+ ?or_test: or_test OR_OP and_test -> binary_op
36
+ | and_test
37
+
38
+ ?and_test: and_test AND_OP not_test -> binary_op
39
+ | not_test
40
+
41
+ ?not_test: NOT_OP not_test -> unary_op
37
42
  | comparison
38
- | atom
39
- comparison: atom comp_op atom
40
- comp_op: COMPARISON_OP
43
+
44
+ # all comparisons have same precedence
45
+ ?comparison: comparison COMPARISON_OP sum -> binary_op
46
+ | sum
47
+
48
+ ?sum: sum ADD_OP term -> binary_op
49
+ | sum SUB_OP term -> binary_op
50
+ | term
51
+
52
+ ?term: term MUL_OP factor -> binary_op
53
+ | term DIV_OP factor -> binary_op
54
+ | term FLOOR_DIV_OP factor -> binary_op
55
+ | term MOD_OP factor -> binary_op
56
+ | factor
57
+
58
+ ?factor: ADD_OP factor -> unary_op # unary plus (identity)
59
+ | SUB_OP factor -> unary_op # unary minus (negation)
60
+ | power
61
+
62
+ ?power: atom POW_OP factor -> binary_op
63
+ | atom
41
64
 
42
65
  arguments: _expr ("," _expr)*
43
66
 
@@ -76,13 +99,25 @@ NAME: /[^\W\d]\w*/
76
99
  COMMENT: /#[^\n]*/
77
100
  CONST_TRUE: "True"
78
101
  CONST_FALSE: "False"
102
+ ADD_OP: "+"
103
+ SUB_OP: "-"
104
+ DIV_OP: "/"
105
+ MUL_OP: "*"
106
+ FLOOR_DIV_OP: "//"
107
+ MOD_OP: "%"
108
+ POW_OP: "**"
109
+ OR_OP: "or"
110
+ AND_OP: "and"
111
+ NOT_OP: "not"
79
112
  COMPARISON_OP: ">" | "<" | "<=" | ">=" | "==" | "!="
80
113
 
81
114
  STRING: /("(?!"").*?(?<!\\)(\\\\)*?"|'(?!'').*?(?<!\\)(\\\\)*?')/i
82
115
 
116
+ DEC_NUMBER: "1".."9" ("_"? "0".."9" )*
117
+ | "0" ("_"? "0" )* /(?![1-9])/
118
+
83
119
  _SPECIAL_DEC: "0".."9" ("_"? "0".."9" )*
84
- DEC_NUMBER: "-"? "1".."9" ("_"? "0".."9" )*
85
- | "-"? "0" ("_"? "0" )* /(?![1-9])/
86
120
 
87
121
  DECIMAL: "." _SPECIAL_DEC | _SPECIAL_DEC "." _SPECIAL_DEC?
88
- FLOAT_NUMBER.2: "-"? _SPECIAL_DEC DECIMAL ["e" ["-"] _SPECIAL_DEC]
122
+ _EXP: ("e"|"E") ["+" | "-"] _SPECIAL_DEC
123
+ FLOAT_NUMBER.2: _SPECIAL_DEC _EXP | DECIMAL _EXP?
@@ -1,12 +1,14 @@
1
1
  import argparse
2
2
  from pathlib import Path
3
3
 
4
+ from fprime_gds.common.fpy.bytecode.assembler import deserialize_directives
5
+ import fprime_gds.common.fpy.model
6
+ from fprime_gds.common.fpy.model import DirectiveErrorCode, FpySequencerModel
4
7
  from fprime_gds.common.fpy.parser import parse
5
- from fprime_gds.common.fpy.codegen import compile
6
- from fprime_gds.common.fpy.bytecode.directives import serialize_directives
8
+ from fprime_gds.common.fpy.codegen import compile, serialize_directives
7
9
 
8
10
 
9
- def main():
11
+ def compile_main():
10
12
  arg_parser = argparse.ArgumentParser()
11
13
  arg_parser.add_argument("input", type=Path, help="The input .fpy file")
12
14
  arg_parser.add_argument(
@@ -37,4 +39,25 @@ def main():
37
39
  if output is None:
38
40
  output = args.input.with_suffix(".bin")
39
41
  serialize_directives(directives, output)
40
- print("Done")
42
+ print("Done")
43
+
44
+
45
+ def model_main():
46
+ arg_parser = argparse.ArgumentParser()
47
+ arg_parser.add_argument("input", type=Path, help="The input .bin file")
48
+ arg_parser.add_argument("--verbose", "-v", action="store_true", help="Whether or not to print stack during sequence execution")
49
+
50
+ args = arg_parser.parse_args()
51
+
52
+ if not args.input.exists():
53
+ print(f"Input file {args.input} does not exist")
54
+ exit(-1)
55
+
56
+ if args.verbose:
57
+ fprime_gds.common.fpy.model.debug = True
58
+
59
+ directives = deserialize_directives(args.input.read_bytes())
60
+ model = FpySequencerModel()
61
+ ret = model.run(directives)
62
+ if ret != DirectiveErrorCode.NO_ERROR:
63
+ print("Sequence failed with " + str(ret))