Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from GingerIndustries/dev
Browse files Browse the repository at this point in the history
Added stuff
  • Loading branch information
gingershaped committed Mar 10, 2022
2 parents 60b7861 + 963c25e commit 015c701
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .breakpoints
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"files": {}
}
11 changes: 8 additions & 3 deletions etch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
from etch.parser.lexer import EtchLexer
from etch.utils import *
from etch.instructions import *
from etch.instructions.operators import *
import etch.mixins
from operator import *
import importlib

__version__ = "0.2.1"
__version__ = "0.2.2"
__doc__ = '''Etch, an easy-to-use high-level interpreted language based off of Python.'''

MATH = {
"+": add,
"+": e_add,
"-": sub,
"*": mul,
"/": truediv,
Expand Down Expand Up @@ -107,15 +108,19 @@ def processBlock(self, instruction):
return ForInstruction(self, params[0], self.processInstruction(params[1]), self.processStatements(params[2]))


def parse(self,code):
def parse(self, code):
if not code.endswith("\n"):
code += "\n" # dirty trailing newline hacks
return self.parser.parse(self.lexer.tokenize(code))
def interpret(self, ast):
if not ast:
return
if self.debug:
print("Parsed AST:", ast)
return [self.processInstruction(i) for i in ast]
def execute(self, instructions):
if not instructions:
return
for i in instructions:
i.execute(self.__context__)
def run(self, code):
Expand Down
Binary file modified etch/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified etch/__pycache__/utils.cpython-38.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion etch/instructions.py → etch/instructions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ def execute(self, context):
"max": max,
"int": lambda x: int(x),
"float": float,
"abs": abs
"abs": abs,
"range": range
}
8 changes: 8 additions & 0 deletions etch/instructions/operators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from operator import *

def e_add(x, y):
if type(x) == str:
return add(x, str(y))
else:
return add(x, y)

Binary file modified etch/parser/__pycache__/lexer.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion etch/parser/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class EtchLexer(Lexer):
tokens = set.union(keywords, symbols)
ignore = " \t"

NEWLINE = r"\n"
NEWLINE = r"\n+"

OPEN_SQ = r"\["
CLOSE_SQ = r"\]"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Etch, an easy-to use, high-level, interpreted lang based on Pytho
name = "etchlang"
readme = "README.md"
repository = "https://github.com/GingerIndustries/Etch"
version = "0.2.1"
version = "0.2.2"
[tool.poetry.dependencies]
python = "^3.8"
sly = "^0.4"
Expand Down

0 comments on commit 015c701

Please sign in to comment.