llparse 0.1.9__tar.gz → 0.2.0__tar.gz

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 (40) hide show
  1. {llparse-0.1.9 → llparse-0.2.0}/PKG-INFO +11 -4
  2. {llparse-0.1.9 → llparse-0.2.0}/README.md +10 -3
  3. {llparse-0.1.9 → llparse-0.2.0}/llparse/C_compiler.py +1 -1
  4. {llparse-0.1.9 → llparse-0.2.0}/llparse/compilator.py +3 -4
  5. {llparse-0.1.9 → llparse-0.2.0}/llparse.egg-info/PKG-INFO +11 -4
  6. {llparse-0.1.9 → llparse-0.2.0}/llparse.egg-info/SOURCES.txt +1 -0
  7. {llparse-0.1.9 → llparse-0.2.0}/pyproject.toml +1 -1
  8. llparse-0.2.0/tests/test_compilator.py +54 -0
  9. {llparse-0.1.9 → llparse-0.2.0}/LICENSE +0 -0
  10. {llparse-0.1.9 → llparse-0.2.0}/llparse/__init__.py +0 -0
  11. {llparse-0.1.9 → llparse-0.2.0}/llparse/constants.py +0 -0
  12. {llparse-0.1.9 → llparse-0.2.0}/llparse/cython_builder.py +0 -0
  13. {llparse-0.1.9 → llparse-0.2.0}/llparse/debug.py +0 -0
  14. {llparse-0.1.9 → llparse-0.2.0}/llparse/dot.py +0 -0
  15. {llparse-0.1.9 → llparse-0.2.0}/llparse/enumerator.py +0 -0
  16. {llparse-0.1.9 → llparse-0.2.0}/llparse/errors.py +0 -0
  17. {llparse-0.1.9 → llparse-0.2.0}/llparse/frontend.py +0 -0
  18. {llparse-0.1.9 → llparse-0.2.0}/llparse/header.py +0 -0
  19. {llparse-0.1.9 → llparse-0.2.0}/llparse/llparse.py +0 -0
  20. {llparse-0.1.9 → llparse-0.2.0}/llparse/pybuilder/__init__.py +0 -0
  21. {llparse-0.1.9 → llparse-0.2.0}/llparse/pybuilder/builder.py +0 -0
  22. {llparse-0.1.9 → llparse-0.2.0}/llparse/pybuilder/loopchecker.py +0 -0
  23. {llparse-0.1.9 → llparse-0.2.0}/llparse/pybuilder/main_code.py +0 -0
  24. {llparse-0.1.9 → llparse-0.2.0}/llparse/pybuilder/parsemap.py +0 -0
  25. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/__init__.py +0 -0
  26. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/code.py +0 -0
  27. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/implementation.py +0 -0
  28. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/namespace.py +0 -0
  29. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/nodes.py +0 -0
  30. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/peephole.py +0 -0
  31. {llparse-0.1.9 → llparse-0.2.0}/llparse/pyfront/transform.py +0 -0
  32. {llparse-0.1.9 → llparse-0.2.0}/llparse/settings.py +0 -0
  33. {llparse-0.1.9 → llparse-0.2.0}/llparse/spanalloc.py +0 -0
  34. {llparse-0.1.9 → llparse-0.2.0}/llparse/trie.py +0 -0
  35. {llparse-0.1.9 → llparse-0.2.0}/llparse.egg-info/dependency_links.txt +0 -0
  36. {llparse-0.1.9 → llparse-0.2.0}/llparse.egg-info/top_level.txt +0 -0
  37. {llparse-0.1.9 → llparse-0.2.0}/setup.cfg +0 -0
  38. {llparse-0.1.9 → llparse-0.2.0}/tests/test_frontend.py +0 -0
  39. {llparse-0.1.9 → llparse-0.2.0}/tests/test_loop_checker.py +0 -0
  40. {llparse-0.1.9 → llparse-0.2.0}/tests/test_span_allocator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llparse
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: A Parody of llparse written for writing C Parsers with Python
5
5
  Author-email: Vizonex <VizonexBusiness@gmail.com>
6
6
  Requires-Python: >=3.9
@@ -15,15 +15,16 @@ Dynamic: license-file
15
15
 
16
16
  A python parody of the typescript library llparse.
17
17
 
18
- I take no credit for the orginal work done by indutny and the other node-js contributors involved and I was originally very nervous about making
19
- this python library that I made public...
18
+ I take no credit for the orginal work done by indutny and the other node-js contributors involved and my additional
19
+ features were meant to inspire activity with the original library again.
20
20
 
21
21
  Links to the original library
22
22
  - https://llparse.org
23
23
  - https://github.com/nodejs/llparse
24
24
 
25
25
  Unlike the typescript library all 3 of llparse's libraries were combined in this version of the code for the sake of portability...
26
- I ended up mentioning how I did this a while back and I also had a concept for a C parser as well but I just didn't like it and I ended up using this instead but I also learned typescript as a bonus and It was alot of fun for me. I don't plan to make this into a real pypi library yet but I also didn't want to take away from the magic of the original source code that I borrowed from...
26
+ I ended up mentioning how I did this a while back and I also had a concept for a C parser as well but I just didn't like it and I ended up using this instead but I also learned typescript as a bonus and It was alot of fun for me. I don't plan to make this into a real pypi library yet but I also didn't want to take away from the magic of the original source code that I borrowed from.
27
+
27
28
 
28
29
  # Looking back on my dead work 2 years later
29
30
  I had this idea lay somewhat dormant for 2 years and now seeing that I wanted to write a new socks5 server parser writing it in python
@@ -134,3 +135,9 @@ open("http_parser.h", "w").write(c.header)
134
135
 
135
136
  ## Video Showcasing this library
136
137
  - https://youtu.be/YQOzJ2BghQw
138
+
139
+ ## Examples of this library being in use
140
+ - [llh2](https://github.com/Vizonex/llh2) I would like to move to the typescript version once my ideas and
141
+ features I've added in get fully implemented but we shall wait and see...
142
+
143
+
@@ -5,15 +5,16 @@
5
5
 
6
6
  A python parody of the typescript library llparse.
7
7
 
8
- I take no credit for the orginal work done by indutny and the other node-js contributors involved and I was originally very nervous about making
9
- this python library that I made public...
8
+ I take no credit for the orginal work done by indutny and the other node-js contributors involved and my additional
9
+ features were meant to inspire activity with the original library again.
10
10
 
11
11
  Links to the original library
12
12
  - https://llparse.org
13
13
  - https://github.com/nodejs/llparse
14
14
 
15
15
  Unlike the typescript library all 3 of llparse's libraries were combined in this version of the code for the sake of portability...
16
- I ended up mentioning how I did this a while back and I also had a concept for a C parser as well but I just didn't like it and I ended up using this instead but I also learned typescript as a bonus and It was alot of fun for me. I don't plan to make this into a real pypi library yet but I also didn't want to take away from the magic of the original source code that I borrowed from...
16
+ I ended up mentioning how I did this a while back and I also had a concept for a C parser as well but I just didn't like it and I ended up using this instead but I also learned typescript as a bonus and It was alot of fun for me. I don't plan to make this into a real pypi library yet but I also didn't want to take away from the magic of the original source code that I borrowed from.
17
+
17
18
 
18
19
  # Looking back on my dead work 2 years later
19
20
  I had this idea lay somewhat dormant for 2 years and now seeing that I wanted to write a new socks5 server parser writing it in python
@@ -124,3 +125,9 @@ open("http_parser.h", "w").write(c.header)
124
125
 
125
126
  ## Video Showcasing this library
126
127
  - https://youtu.be/YQOzJ2BghQw
128
+
129
+ ## Examples of this library being in use
130
+ - [llh2](https://github.com/Vizonex/llh2) I would like to move to the typescript version once my ideas and
131
+ features I've added in get fully implemented but we shall wait and see...
132
+
133
+
@@ -176,7 +176,7 @@ class CCompiler:
176
176
  posField = ctx.spanPosField(span.index)
177
177
 
178
178
  if len(span.callbacks) == 1:
179
- cb = ctx.unwrapCode(span.callbacks[0], True)
179
+ cb = ctx.unwrapCode(span.callbacks[0])
180
180
  callback = ctx.buildCode(cb)
181
181
 
182
182
  else:
@@ -620,7 +620,7 @@ class SpanStart(Node):
620
620
 
621
621
  if len(field.callbacks) > 1:
622
622
  cbField = ctx.spanCbField(field.index)
623
- callback = ctx.unwrapCode(self.ref.callback, True)
623
+ callback = ctx.unwrapCode(self.ref.callback)
624
624
  out.append(f"{cbField} = {ctx.buildCode(callback)};")
625
625
 
626
626
  otherwise = self.ref.otherwise
@@ -648,7 +648,7 @@ class SpanEnd(Node):
648
648
  out.append(f"{posField} = NULL;")
649
649
 
650
650
  # Invoke callback
651
- callback = ctx.buildCode(ctx.unwrapCode(self.ref.callback, True))
651
+ callback = ctx.buildCode(ctx.unwrapCode(self.ref.callback))
652
652
 
653
653
  out.append(f"err = {callback}({ctx.stateArg()}, start, {ctx.posArg()});")
654
654
 
@@ -1121,8 +1121,7 @@ class Compilation:
1121
1121
  def reserveSpans(self, spans: list[_frontend.node.SpanField]):
1122
1122
  for span in spans:
1123
1123
  for callback in span.callbacks:
1124
- cb = self.unwrapCode(callback)
1125
- if cb:
1124
+ if cb := self.unwrapCode(callback):
1126
1125
  self.buildCode(cb)
1127
1126
 
1128
1127
  def debug(self, out: list[str], message: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llparse
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: A Parody of llparse written for writing C Parsers with Python
5
5
  Author-email: Vizonex <VizonexBusiness@gmail.com>
6
6
  Requires-Python: >=3.9
@@ -15,15 +15,16 @@ Dynamic: license-file
15
15
 
16
16
  A python parody of the typescript library llparse.
17
17
 
18
- I take no credit for the orginal work done by indutny and the other node-js contributors involved and I was originally very nervous about making
19
- this python library that I made public...
18
+ I take no credit for the orginal work done by indutny and the other node-js contributors involved and my additional
19
+ features were meant to inspire activity with the original library again.
20
20
 
21
21
  Links to the original library
22
22
  - https://llparse.org
23
23
  - https://github.com/nodejs/llparse
24
24
 
25
25
  Unlike the typescript library all 3 of llparse's libraries were combined in this version of the code for the sake of portability...
26
- I ended up mentioning how I did this a while back and I also had a concept for a C parser as well but I just didn't like it and I ended up using this instead but I also learned typescript as a bonus and It was alot of fun for me. I don't plan to make this into a real pypi library yet but I also didn't want to take away from the magic of the original source code that I borrowed from...
26
+ I ended up mentioning how I did this a while back and I also had a concept for a C parser as well but I just didn't like it and I ended up using this instead but I also learned typescript as a bonus and It was alot of fun for me. I don't plan to make this into a real pypi library yet but I also didn't want to take away from the magic of the original source code that I borrowed from.
27
+
27
28
 
28
29
  # Looking back on my dead work 2 years later
29
30
  I had this idea lay somewhat dormant for 2 years and now seeing that I wanted to write a new socks5 server parser writing it in python
@@ -134,3 +135,9 @@ open("http_parser.h", "w").write(c.header)
134
135
 
135
136
  ## Video Showcasing this library
136
137
  - https://youtu.be/YQOzJ2BghQw
138
+
139
+ ## Examples of this library being in use
140
+ - [llh2](https://github.com/Vizonex/llh2) I would like to move to the typescript version once my ideas and
141
+ features I've added in get fully implemented but we shall wait and see...
142
+
143
+
@@ -32,6 +32,7 @@ llparse/pyfront/namespace.py
32
32
  llparse/pyfront/nodes.py
33
33
  llparse/pyfront/peephole.py
34
34
  llparse/pyfront/transform.py
35
+ tests/test_compilator.py
35
36
  tests/test_frontend.py
36
37
  tests/test_loop_checker.py
37
38
  tests/test_span_allocator.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llparse"
3
- version = "0.1.9"
3
+ version = "0.2.0"
4
4
  description = "A Parody of llparse written for writing C Parsers with Python"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -0,0 +1,54 @@
1
+ # The good old http_parser was borrowed from llparse.org to demonstrate this for you :)
2
+ from llparse import LLParse
3
+
4
+
5
+ def test_http_parser_example():
6
+
7
+ p = LLParse("http_parser")
8
+ method = p.node("method")
9
+ beforeUrl = p.node("before_url")
10
+ urlSpan = p.span(p.code.span("on_url"))
11
+ url = p.node("url")
12
+ http = p.node("http")
13
+
14
+ # Add custom uint8_t property to the state
15
+ p.property("i8", "method")
16
+
17
+ # Store method inside a custom property
18
+ onMethod = p.invoke(p.code.store("method"), beforeUrl)
19
+
20
+ # Invoke custom C function
21
+ complete = p.invoke(
22
+ p.code.match("on_complete"),
23
+ {
24
+ # Restart
25
+ 0: method
26
+ },
27
+ p.error(4, "`on_complete` error"),
28
+ )
29
+
30
+ method.select(
31
+ {
32
+ "HEAD": 0,
33
+ "GET": 1,
34
+ "POST": 2,
35
+ "PUT": 3,
36
+ "DELETE": 4,
37
+ "OPTIONS": 5,
38
+ "CONNECT": 6,
39
+ "TRACE": 7,
40
+ "PATCH": 8,
41
+ },
42
+ onMethod,
43
+ ).otherwise(p.error(5, "Expected method"))
44
+
45
+ beforeUrl.match(" ", beforeUrl).otherwise(urlSpan.start(url))
46
+
47
+ url.peek(" ", urlSpan.end(http)).skipTo(url)
48
+
49
+ http.match(" HTTP/1.1\r\n\r\n", complete).otherwise(
50
+ p.error(6, "Expected HTTP/1.1 and two newlines")
51
+ )
52
+
53
+ # if this build fails in any way then we have failed...
54
+ c = p.build(method)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes