Skip to content

Commit

Permalink
added more easier way to add internal functions, among other things
Browse files Browse the repository at this point in the history
  • Loading branch information
TechStudent10 committed Sep 29, 2021
1 parent e3d5c2c commit 83afcdc
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.pyc
__pycache__/
__pycache__/
output/
pyinstaller_beta.json
venv/
31 changes: 20 additions & 11 deletions orange/_parser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from . import constants

from .internal_functions._get_value import get_value

functions = constants.KEYWORDS
from .keywords import KEYWORDS

variables = {}
functions = {}

def parse(code):
code_lines = code.split('\n')
Expand All @@ -14,19 +12,30 @@ def parse(code):
if line == '':
continue
line_split = line.split(':')
# print(line_split)
name = line_split[0]
if name.startswith('#'):
continue

del line_split[0]
val_not_convert = ':'.join(line_split)
args = val_not_convert.split(',')
new_args = []
for arg in args:
if arg.startswith(' '):
arg = arg[1:]

new_arg = get_value(arg, variables=variables, line_number=line_number)
new_args.append(new_arg)


if val_not_convert.startswith(' '):
val_not_convert = val_not_convert[1:]
value = get_value(val_not_convert, line_number=line_number + 1, variables=variables)
# print("val", value)
if name in constants.KEYWORDS:

val_not_convert = ',' + val_not_convert
if name in KEYWORDS:
if name.startswith(' '):
name = name[1:]

if name == 'print':
functions['print'](value)
KEYWORDS[name](new_args)
else:
variables[name] = value
variables[name] = ' '.join(new_args)
49 changes: 49 additions & 0 deletions orange/comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# print(new_args)
# print(name)
# print(value)
# if name == 'function':
# function = {}
# function_name = val_not_convert.split(',')[0]
# function_lines = []
# current_num = line_number + 1
# current_space_count = 0
# while 1:
# function_line = code_lines[current_num]
# print('func line:', function_line)
# if len(function_lines) == 0:
# print('no function lines')
# space_count = 0
# print('no space count')
# for char in function_line:
# if char == ' ':
# print('char is a space character')
# space_count += 1
# elif char == ' ':
# print('char is a tab character')
# space_count += 4

# current_space_count = space_count
# print('current space_count:', current_space_count)

# if function_line.startswith(' '*current_space_count):
# print('function line starts with space with space count')
# function_lines.append(function_line.strip(' '*current_space_count))
# elif function_line.startswith("}"):
# print('function lines end')
# break

# function['name'] = function_name
# function['lines'] = function_lines
# print(function)
# functions[function_name] = function
# print(val_not_convert)
# value = get_value(val_not_convert, line_number=line_number + 1, variables=variables)
# print("val", value)

# if name=="blah": print(new_args)
# print(line_split)
# function: functionName, ( name, another ) {
# print: name
# }
# execute: "functionName", "another"
# from .internal_functions import print
7 changes: 4 additions & 3 deletions orange/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .internal_functions import _print

KEYWORDS = {
'print':_print,
}
KEYWORDS = [
'print',
'function'
]
4 changes: 2 additions & 2 deletions orange/internal_functions/print.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def _print(*args, **kwargs):
print(*args, **kwargs)
def _print(args):
print(' '.join(args))
5 changes: 5 additions & 0 deletions orange/keywords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .internal_functions.print import _print

KEYWORDS = {
'print': _print,
}
73 changes: 73 additions & 0 deletions pyinstaller.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": "auto-py-to-exe-configuration_v1",
"pyinstallerOptions": [
{
"optionDest": "noconfirm",
"value": true
},
{
"optionDest": "filenames",
"value": "P:/Orange/run.py"
},
{
"optionDest": "onefile",
"value": true
},
{
"optionDest": "console",
"value": true
},
{
"optionDest": "name",
"value": "orange"
},
{
"optionDest": "ascii",
"value": false
},
{
"optionDest": "clean_build",
"value": false
},
{
"optionDest": "strip",
"value": false
},
{
"optionDest": "noupx",
"value": false
},
{
"optionDest": "uac_admin",
"value": false
},
{
"optionDest": "uac_uiaccess",
"value": false
},
{
"optionDest": "win_private_assemblies",
"value": false
},
{
"optionDest": "win_no_prefer_redirects",
"value": false
},
{
"optionDest": "bootloader_ignore_signals",
"value": false
},
{
"optionDest": "disable_windowed_traceback",
"value": false
},
{
"optionDest": "datas",
"value": "P:/Orange/orange;orange/"
}
],
"nonPyinstallerOptions": {
"increaseRecursionLimit": true,
"manualArguments": ""
}
}
2 changes: 1 addition & 1 deletion test.or
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var1: "yep"
print: var1
print: var1

0 comments on commit 83afcdc

Please sign in to comment.