Skip to content

Commit

Permalink
implemented (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jodus-Melodus authored Jul 29, 2024
1 parent 550c3b6 commit 4d0db78
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
Binary file modified __pycache__/Dropdown.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/TerminalRedirect.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/shell.cpython-311.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion ast.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"kind": "program", "body": [{"kind": "variableDeclarationExpression", "datatype": "array", "identifier": "test", "value": {"kind": "arrayLiteral", "items": [{"kind": "itemLiteral", "index": 0, "value": {"kind": "integerLiteral", "value": 53}}, {"kind": "itemLiteral", "index": 1, "value": {"kind": "integerLiteral", "value": 34}}, {"kind": "itemLiteral", "index": 2, "value": {"kind": "integerLiteral", "value": 64}}, {"kind": "itemLiteral", "index": 3, "value": {"kind": "integerLiteral", "value": 31}}]}, "constant": "False"}, {"kind": "forEachStatement", "declaration": {"kind": "variableDeclarationExpression", "datatype": "int", "identifier": "i", "value": {"kind": "integerLiteral", "value": 0}, "constant": "False"}, "iterable": {"kind": "identifier", "symbol": "test"}, "body": [{"kind": "callExpression", "arguments": [{"kind": "identifier", "symbol": "i"}], "caller": {"kind": "identifier", "symbol": "output"}}]}]}
{"kind": "program", "body": [{"kind": "variableDeclarationExpression", "datatype": "array", "identifier": "test", "value": {"kind": "arrayLiteral", "items": [{"kind": "itemLiteral", "index": 0, "value": {"kind": "integerLiteral", "value": 53}}, {"kind": "itemLiteral", "index": 1, "value": {"kind": "integerLiteral", "value": 34}}, {"kind": "itemLiteral", "index": 2, "value": {"kind": "integerLiteral", "value": 64}}, {"kind": "itemLiteral", "index": 3, "value": {"kind": "integerLiteral", "value": 31}}]}, "constant": "False"}, {"kind": "forEachStatement", "declaration": {"kind": "variableDeclarationExpression", "datatype": "int", "identifier": "i", "value": {"kind": "integerLiteral", "value": 0}, "constant": "False"}, "iterable": {"kind": "identifier", "symbol": "test"}, "body": [{"kind": "callExpression", "arguments": [{"kind": "identifier", "symbol": "i"}], "caller": {"kind": "identifier", "symbol": "output"}}]}, {"kind": "identifier", "symbol": "hello"}, {"kind": "identifier", "symbol": "world"}, {"kind": "identifier", "symbol": "how"}, {"kind": "identifier", "symbol": "are"}, {"kind": "identifier", "symbol": "you"}, {"kind": "identifier", "symbol": "ding"}]}
21 changes: 15 additions & 6 deletions phIDE.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def bind_keys(self) -> None:
# Double Character Sequence
self.bind("<Control-F4>", self.close_file)
self.bind("<Control-BackSpace>", self.backspace_entire_word)
self.bind("<Control-space>", self.show_intelli_sense)
self.bind("<Control-Space>", self.show_intelli_sense)
self.bind("<Control-Tab>", self.next_tab)
self.bind("<Control-/>", self.comment_line)
self.bind("<Control-;>", self.show_snippets)
Expand Down Expand Up @@ -765,7 +765,18 @@ def load_language_syntax(self) -> None:
self.bell()

def update_syntax(self) -> None:
if editor := self.current_tab:
while True:
if not (editor := self.current_tab):
continue

current_code = editor.get("0.0", "end")

if self.code == current_code:
continue

self.code = current_code
self.get_warnings(editor, current_code)

for tag in self.language_syntax_patterns[self.current_language]:
pattern = self.language_syntax_patterns[self.current_language][tag][1]
editor.tag_remove(tag, "0.0", "end")
Expand All @@ -776,14 +787,12 @@ def update_syntax(self) -> None:
for line_number in range(int(first_visible_index.split(".")[0]), int(last_visible_index.split(".")[0]) + 1):
text = editor.get(f"{line_number}.0", f"{line_number}.end")
matches = [(match.start(), match.end())
for match in re.finditer(pattern, text, re.MULTILINE)]
for match in re.finditer(pattern, text, re.MULTILINE)]

for start, end in matches:
editor.tag_add(
tag, f"{line_number}.{start}", f"{line_number}.{end}")

time.sleep(0.1)
self.update_syntax()
time.sleep(0.1)

# IntelliSense
def up_key_press(self, _=None) -> None:
Expand Down
4 changes: 4 additions & 0 deletions test.phi
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ for each (int i in test){
output(i)
}




hello world how are you ding

0 comments on commit 4d0db78

Please sign in to comment.