diff --git a/PLAN.md b/PLAN.md index 5a6a823..a83cef3 100644 --- a/PLAN.md +++ b/PLAN.md @@ -4,7 +4,7 @@ |✅|75% :octocat:||0% :octocat:||| |:-:|:-:|:-:|:-:|:-:|:-:| -|**Start**|L1 parser|L2 parser *(only for PERFORM. See [stream.py](./src/stream/stream.py))*|syntax checker|runtime|**Release**| +|**Start**|L1 parser|L2 parser *(only for PERFORM. See [stream.py](./src/stream/parser/stream.py))*|syntax checker|runtime|**Release**| ✅ : Finished :octocat: : Working diff --git a/src/stream/CI_TEST.py b/src/stream/CI_TEST.py index a8a4ad8..66a0241 100644 --- a/src/stream/CI_TEST.py +++ b/src/stream/CI_TEST.py @@ -7,4 +7,9 @@ Mention @Diggie-Bro/froglang for any help! """ +# L1 parser +from .parser import parse + +parse.Generator() + diff --git a/src/stream/__init__.py b/src/stream/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/stream/parser/__init__.py b/src/stream/parser/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/stream/parser/__init__.py @@ -0,0 +1 @@ + diff --git a/src/stream/keywords.py b/src/stream/parser/keywords.py similarity index 91% rename from src/stream/keywords.py rename to src/stream/parser/keywords.py index 1792896..e74c935 100644 --- a/src/stream/keywords.py +++ b/src/stream/parser/keywords.py @@ -2,7 +2,7 @@ StreamCode Prototype, under Froglang keywords.py -Stream Grammar Keywords file. +Stream Grammar Keywords File for parsing Mention @Diggie-Bro/froglang for any help! """ diff --git a/src/stream/parse.py b/src/stream/parser/parse.py similarity index 98% rename from src/stream/parse.py rename to src/stream/parser/parse.py index 20b8b6f..9f1486c 100644 --- a/src/stream/parse.py +++ b/src/stream/parser/parse.py @@ -6,7 +6,7 @@ Mention @Diggie-Bro/froglang for any help! """ -import stream +from . import stream class Generator: def __init__(self, codepath, targetpath): diff --git a/src/stream/parse_test.py b/src/stream/parser/parse_test.py similarity index 89% rename from src/stream/parse_test.py rename to src/stream/parser/parse_test.py index 5a31809..5381621 100644 --- a/src/stream/parse_test.py +++ b/src/stream/parser/parse_test.py @@ -1,4 +1,4 @@ -import parse +from . import parse if __name__ == '__main__': parser = parse.Generator(codepath="proto/basic.streamcode", targetpath="proto/basic_parsed.streamparse") diff --git a/src/stream/proto/basic.streamcode b/src/stream/parser/proto/basic.streamcode similarity index 100% rename from src/stream/proto/basic.streamcode rename to src/stream/parser/proto/basic.streamcode diff --git a/src/stream/proto/basic_parsed.streamparse b/src/stream/parser/proto/basic_parsed.streamparse similarity index 100% rename from src/stream/proto/basic_parsed.streamparse rename to src/stream/parser/proto/basic_parsed.streamparse diff --git a/src/stream/stream.py b/src/stream/parser/stream.py similarity index 91% rename from src/stream/stream.py rename to src/stream/parser/stream.py index 205453e..f2872f9 100644 --- a/src/stream/stream.py +++ b/src/stream/parser/stream.py @@ -2,13 +2,12 @@ StreamCode Prototype, under Froglang stream.py -Stream Structure Object File +Stream Structure Object File for Parsing Mention @Diggie-Bro/froglang for any help! """ -import re -import keywords -import string_obfuscation as strobfus +from . import keywords +from . import string_obfuscation as strobfus """ Stream Class @@ -18,12 +17,14 @@ :param code: str """ + + class Stream: def __init__(self, code: str): self.code = code self.stream = [] self.metadata = {} - + def makeStructure(self): self.metadata = { "variableStream": True if ":=" in self.code else False, @@ -36,7 +37,7 @@ def makeStructure(self): for index, code in enumerate(codes): code.strip() - + # string obfuscation not to confuse during parsing. # string only support ", not ' # multiline support, too @@ -45,19 +46,18 @@ def makeStructure(self): for i, char in enumerate(list(code)): if char == '{': - if braceRangeIndex == None: + if braceRangeIndex is None: braceRangeIndex = i elif char == '}': # suppose grammar is right. - if braceRangeIndex != None: + if braceRangeIndex is not None: multilPart = code[braceRangeIndex + 1: i] multilPart_edited = multilPart.replace("\n", keywords.dummy_keyword["MULTILENTER"]).strip() code = code.replace(multilPart, multilPart_edited) braceRangeIndex = None - for i, char in enumerate(list(code)): if char == '"': - if stringRangeIndex != None: + if stringRangeIndex is not None: stringPart = code[stringRangeIndex + 1: i] code = code.replace(stringPart, strobfus.encode(stringPart)) stringRangeIndex = None diff --git a/src/stream/stream_test.py b/src/stream/parser/stream_test.py similarity index 92% rename from src/stream/stream_test.py rename to src/stream/parser/stream_test.py index d89f920..280b365 100644 --- a/src/stream/stream_test.py +++ b/src/stream/parser/stream_test.py @@ -1,4 +1,4 @@ -import stream +from . import stream if __name__ == '__main__': strm = stream.Stream( diff --git a/src/stream/string_obfuscation.py b/src/stream/parser/string_obfuscation.py similarity index 95% rename from src/stream/string_obfuscation.py rename to src/stream/parser/string_obfuscation.py index 85c67ff..e4ba42f 100644 --- a/src/stream/string_obfuscation.py +++ b/src/stream/parser/string_obfuscation.py @@ -9,7 +9,7 @@ Mention @Diggie-Bro/froglang for any help! """ -import keywords +from . import keywords def encode(s): return keywords.dummy_keyword["OBFUSSTRING"].join([str(ord(c)) for c in list(s)])