rpc-language 2.5__tar.gz → 3.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.
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rpc-language
3
- Version: 2.5
3
+ Version: 3.0
4
4
  Requires-Dist: pyinstaller
5
5
  Dynamic: requires-dist
@@ -3,26 +3,60 @@ import shutil
3
3
  import time
4
4
  import sys
5
5
  import os
6
+ import re
6
7
 
7
8
  class RPC:
8
9
  class NeedSemicolon(Exception):
9
10
  def __init__(self, message):
10
11
  super().__init__(message)
12
+ class MismatchedQuotationMarks(Exception):
13
+ def __init__(self, message):
14
+ super().__init__(message)
11
15
 
12
16
  def parse(line):
13
17
  indent = len(line) - len(line.lstrip())
14
18
  line = line.lstrip()
15
19
  add = False
16
20
 
17
- if line.endswith(";"): line = line[:-1]
18
- elif line == "": pass
19
- elif line.endswith("{"): pass
20
- elif line.endswith("}"): pass
21
- elif line.endswith(">"): pass
22
- elif line.endswith("++"): pass
23
- elif line.endswith("--"): pass
24
- elif line.endswith("?"): pass
25
- else: raise RPC.NeedSemicolon("缺少分号")
21
+ mark1a = 0
22
+ mark1b = 0
23
+ text = line.split("//")[0]
24
+ for i in line:
25
+ if i == "'":
26
+ mark1a += 1
27
+ if i == '"':
28
+ mark1b += 1
29
+
30
+ mark2a = 0
31
+ mark2b = 0
32
+ for i in text:
33
+ if i == "'":
34
+ mark2a += 1
35
+ if i == '"':
36
+ mark2b += 1
37
+
38
+ if mark1a % 2 == 0:
39
+ if mark1b % 2 == 0:
40
+ pass
41
+ else:
42
+ raise RPC.MismatchedQuotationMarks("不匹配的引号")
43
+ else:
44
+ raise RPC.MismatchedQuotationMarks("不匹配的引号")
45
+
46
+ if "//" in line:
47
+ if mark2a % 2 == 0 or mark2a == 0:
48
+ if mark2b % 2 == 0 or mark2b == 0:
49
+ line = line.split("//")[0].rstrip()
50
+
51
+ if line.endswith(";"): line = line[:-1]
52
+ elif line == "": pass
53
+ elif line.endswith("{"): pass
54
+ elif line.endswith("}"): pass
55
+ elif line.endswith(">"): pass
56
+ elif line.endswith("++"): pass
57
+ elif line.endswith("--"): pass
58
+ elif line.endswith("?"): pass
59
+ else: raise RPC.NeedSemicolon("缺少分号")
26
60
 
27
61
  if line.startswith("loop"):
28
62
  if line.endswith("loop"):
@@ -36,15 +70,12 @@ def parse(line):
36
70
  ok = False
37
71
 
38
72
  if ok is True:
39
- if line.endswith("{"):
40
- line = f"for _ in range({line[5:-1].rstrip()})" + line[-1]
41
- else:
42
- line = f"for _ in range({line[5:-1].rstrip()}):" + line[-1]
73
+ line = f"for _ in range({line[5:-1].rstrip()}):"
43
74
  else:
44
75
  if line.endswith("{"):
45
- line = "while True" + line[4:]
76
+ line = "while True:" + line[4:-1].rstrip()
46
77
  else:
47
- line = "while True:" + line[4:]
78
+ line = "while True:" + line[4:].rstrip()
48
79
 
49
80
  if line.startswith("fn "):
50
81
  line = 'def ' + line[3:]
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rpc-language
3
- Version: 2.5
3
+ Version: 3.0
4
4
  Requires-Dist: pyinstaller
5
5
  Dynamic: requires-dist
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name="rpc-language",
5
- version="2.5",
5
+ version="3.0",
6
6
  py_modules=["rpc"],
7
7
  install_requires=["pyinstaller"],
8
8
  entry_points={
File without changes