-
Notifications
You must be signed in to change notification settings - Fork 0
/
xent.py
126 lines (103 loc) · 2.98 KB
/
xent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from sys import argv, dont_write_bytecode
dont_write_bytecode = True
from time import *
import os
def lex(v1):
output = ""
# list
LIN = list(v1)
# current character
char = ""
# string of data
stri = ""
# state of data
state = 0
# state 0: default state
# state 1: string printing
# state 2: comment
# state 3: command runner
# if in a string
in_str = 0
# location in LIN variable
location = 0
no_brk = 0
cmd_run = ""
args = argv[2:]
# argument basic syntax
#logic IF
arg1 = ""
arg2 = ""
prev_char=""
for char in LIN:
location += 1
stri += char
#print (str)
if char == " " and ( state == 0 or state == -1 ) and in_str == 0:
stri = ""
elif char == "!" and state == 0 and in_str == 0:
stri = ""
elif char == "\n" and state == 0 and in_str == 0:
stri = ""
# print
elif stri == "PRINT" and state == 0:
state = 1
stri = ""
elif stri == "print" and state == 0: # in case somebody forgets capitals
state = 1
stri = ""
elif (char == "\"" or char == "\'") and state == 1 and in_str == 0:
in_str = 1
stri = ""
elif state == 1 and in_str == 1 and (char == "\"" or char == "\'"):
in_str = 0
print(stri[:-1])
stri = ""
state = 0
# comments
elif state == 0 and stri == "~":
state = 2
stri = ""
elif state == 2 and char == "~":
state = 0
stri = ""
#macros
elif state == 0 and char == "%":
#macro instator
state = 3
stri = ""
elif state == 3 and char == "%":
if len(stri) > 253194:
print("WARNING: macro is over or equal to 253,195 characters and is at risk of breaking xent, proceed with caution!\n press any key to continue")
input()
print("XenText: i sure hope you know what your doing")
sleep(2)
state = 0
stri = ""
stream = os.popen(cmd_run)
strix = ""
charx = ""
for charx in stream.read():
strix += charx
print(strix)
elif state == 3:
cmd_run += char
stri = ""
#breakpoint @brk
elif state == 0 and no_brk == 0 and stri == "@brk":
input("===")
stri = ""
elif state == 0 and no_brk == 0 and stri == "@nbrk":
no_brk = 1
stri = ""
elif state == 0 and no_brk == 1 and stri == "@ybrk":
no_brk = 0
stri = ""
#======================
#previous character
prev_char = char
# run definition
def run():
gi = open(argv[1], "r")
gi = gi.read()
lex(gi)
run()