linked-data-python 0.0.4__py3-none-any.whl → 0.2.0__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 (41) hide show
  1. ldpy/__init__.py +35 -11
  2. ldpy/__main__.py +75 -250
  3. ldpy/build.py +91 -0
  4. ldpy/console.py +116 -0
  5. ldpy/debug.py +235 -0
  6. ldpy/formatter.py +329 -0
  7. ldpy/importer.py +110 -0
  8. ldpy/lsp/__init__.py +11 -0
  9. ldpy/lsp/__main__.py +4 -0
  10. ldpy/lsp/backend.py +118 -0
  11. ldpy/lsp/rpc.py +104 -0
  12. ldpy/lsp/server.py +353 -0
  13. ldpy/lsp/translate.py +140 -0
  14. ldpy/pygments_lexer.py +613 -0
  15. ldpy/runtime.py +931 -0
  16. ldpy/sparql.py +551 -0
  17. ldpy/transpiler/__init__.py +14 -0
  18. ldpy/transpiler/core.py +2558 -0
  19. ldpy/transpiler/errors.py +38 -0
  20. ldpy/transpiler/linemap.py +292 -0
  21. linked_data_python-0.2.0.dist-info/METADATA +158 -0
  22. linked_data_python-0.2.0.dist-info/RECORD +26 -0
  23. {linked_data_python-0.0.4.dist-info → linked_data_python-0.2.0.dist-info}/WHEEL +1 -1
  24. linked_data_python-0.2.0.dist-info/entry_points.txt +9 -0
  25. {linked_data_python-0.0.4.dist-info → linked_data_python-0.2.0.dist-info/licenses}/LICENSE.md +0 -0
  26. {linked_data_python-0.0.4.dist-info → linked_data_python-0.2.0.dist-info}/top_level.txt +0 -0
  27. ldpy/grun/lib.py +0 -63
  28. ldpy/grun/util.py +0 -11
  29. ldpy/ldpy.py +0 -183
  30. ldpy/rewriter/IndentedStringWriter.py +0 -54
  31. ldpy/rewriter/LDPythonRewriter.py +0 -677
  32. ldpy/rewriter/MultiChannelTokenStream.py +0 -127
  33. ldpy/rewriter/Result.py +0 -49
  34. ldpy/rewriter/__init__.py +0 -7
  35. ldpy/rewriter/antlr/LDPythonLexer.py +0 -870
  36. ldpy/rewriter/antlr/LDPythonParser.py +0 -9336
  37. ldpy/rewriter/antlr/LDPythonVisitor.py +0 -573
  38. ldpy/sparql/builtin.py +0 -326
  39. linked_data_python-0.0.4.dist-info/METADATA +0 -139
  40. linked_data_python-0.0.4.dist-info/RECORD +0 -20
  41. linked_data_python-0.0.4.dist-info/entry_points.txt +0 -3
@@ -1,127 +0,0 @@
1
- #
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 by Maxime Lefrançois
5
- #
6
- # Permission is hereby granted, free of charge, to any person
7
- # obtaining a copy of this software and associated documentation
8
- # files (the "Software"), to deal in the Software without
9
- # restriction, including without limitation the rights to use,
10
- # copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the
12
- # Software is furnished to do so, subject to the following
13
- # conditions:
14
- #
15
- # The above copyright notice and this permission notice shall be
16
- # included in all copies or substantial portions of the Software.
17
- #
18
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
- # OTHER DEALINGS IN THE SOFTWARE.
26
- #
27
- # Project : ldpython-parser; Linked-Data Python to Python/Micropython Rewriter
28
- # https://gitlab.com/coswot/linked-data-python/ldpy
29
- # Developed by : Maxime Lefrançois, maxime.lefrancois@emse.fr
30
- #
31
- from typing import List
32
- from antlr4.Lexer import Lexer
33
- from antlr4.Token import Token
34
- from antlr4.BufferedTokenStream import BufferedTokenStream
35
-
36
- # Fork of CommonTokenStream as explained in https://stackoverflow.com/questions/29060496/allow-whitespace-sections-antlr4/29115489#29115489
37
- class MultiChannelTokenStream(BufferedTokenStream):
38
- __slots__ = 'channels'
39
-
40
- def __init__(self, lexer:Lexer, channels:List[int]=[Token.DEFAULT_CHANNEL]):
41
- super().__init__(lexer)
42
- self.channels = channels
43
-
44
- def disable(self, channel:int):
45
- if channel not in self.channels:
46
- return
47
- self.channels.remove(channel)
48
- self.index = self.nextTokenOnChannel(self.index)
49
-
50
- def enable(self, channel:int):
51
- if channel in self.channels:
52
- return
53
- self.channels += [channel]
54
- i = self.index
55
- while i>0 and i == channel:
56
- i -= 1
57
- self.index = i
58
-
59
- def adjustSeekIndex(self, i:int):
60
- return self.nextTokenOnChannel(i)
61
-
62
- def LB(self, k:int):
63
- if k==0 or (self.index-k)<0:
64
- return None
65
- i = self.index
66
- n = 1
67
- # find k good tokens looking backwards
68
- while n <= k:
69
- # skip off-channel tokens
70
- i = self.previousTokenOnChannel(i - 1)
71
- n += 1
72
- if i < 0:
73
- return None
74
- return self.tokens[i]
75
-
76
- def LT(self, k:int):
77
- self.lazyInit()
78
- if k == 0:
79
- return None
80
- if k < 0:
81
- return self.LB(-k)
82
- i = self.index
83
- n = 1 # we know tokens[pos] is a good one
84
- # find k good tokens
85
- while n < k:
86
- # skip off-channel tokens, but make sure to not look past EOF
87
- if self.sync(i + 1):
88
- i = self.nextTokenOnChannel(i + 1)
89
- n += 1
90
- return self.tokens[i]
91
-
92
- # Count EOF just once.#/
93
- def getNumberOfOnChannelTokens(self):
94
- n = 0
95
- self.fill()
96
- for i in range(0, len(self.tokens)):
97
- t = self.tokens[i]
98
- if t.channel in self.channels:
99
- n += 1
100
- if t.type==Token.EOF:
101
- break
102
- return n
103
-
104
- # Given a starting index, return the index of the next token on one of the channels.
105
- # Return i if tokens[i] is on one of the channels. Return the index of the EOF token
106
- # if there are no tokens on one of the channels between i and EOF.
107
- #/
108
- def nextTokenOnChannel(self, i:int):
109
- self.sync(i)
110
- if i>=len(self.tokens):
111
- return len(self.tokens) - 1
112
- token = self.tokens[i]
113
- while token.channel not in self.channels:
114
- if token.type==Token.EOF:
115
- return i
116
- i += 1
117
- self.sync(i)
118
- token = self.tokens[i]
119
- return i
120
-
121
- # Given a starting index, return the index of the previous token on channel.
122
- # Return i if tokens[i] is on channel. Return -1 if there are no tokens
123
- # on channel between i and 0.
124
- def previousTokenOnChannel(self, i:int):
125
- while i>=0 and self.tokens[i].channel not in self.channels:
126
- i -= 1
127
- return i
ldpy/rewriter/Result.py DELETED
@@ -1,49 +0,0 @@
1
- #
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 by Maxime Lefrançois
5
- #
6
- # Permission is hereby granted, free of charge, to any person
7
- # obtaining a copy of this software and associated documentation
8
- # files (the "Software"), to deal in the Software without
9
- # restriction, including without limitation the rights to use,
10
- # copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the
12
- # Software is furnished to do so, subject to the following
13
- # conditions:
14
- #
15
- # The above copyright notice and this permission notice shall be
16
- # included in all copies or substantial portions of the Software.
17
- #
18
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
- # OTHER DEALINGS IN THE SOFTWARE.
26
- #
27
- # Project : ldpython-parser; Linked-Data Python to Python/Micropython Rewriter
28
- # https://gitlab.com/coswot/linked-data-python/ldpy
29
- # Developed by : Maxime Lefrançois, maxime.lefrancois@emse.fr
30
- #
31
- class Result:
32
-
33
- def __init__(self, out:str = ""):
34
- self.out = out
35
- self.stmts = []
36
- self.post_stmts = []
37
-
38
- def __str__(self):
39
- return self.out
40
-
41
- def add_stmts(self, other, rdfterm:str=None):
42
- for stmt in other.stmts:
43
- if isinstance(stmt, str):
44
- self.stmts.append(stmt)
45
- elif isinstance(stmt, tuple):
46
- if rdfterm is not None and len(stmt)<3:
47
- self.stmts.append((rdfterm, *stmt))
48
- else:
49
- self.stmts.append(stmt)
ldpy/rewriter/__init__.py DELETED
@@ -1,7 +0,0 @@
1
- from ldpy.rewriter.IndentedStringWriter import IndentedStringWriter
2
- from ldpy.rewriter.MultiChannelTokenStream import MultiChannelTokenStream
3
- from ldpy.rewriter.antlr.LDPythonLexer import LDPythonLexer
4
- from ldpy.rewriter.antlr.LDPythonParser import LDPythonParser
5
- from ldpy.rewriter.antlr.LDPythonVisitor import LDPythonVisitor
6
- from ldpy.rewriter.LDPythonRewriter import LDPythonRewriter
7
- from ldpy.rewriter.LDPythonRewriter import LDPythonRewriter