del test file

This commit is contained in:
Christoph Brandau
2025-08-04 16:06:50 +02:00
parent d22d897d23
commit 6a051a6dee
-78
View File
@@ -1,78 +0,0 @@
from tclint.parser import Parser as tcLintParser
from tclint.lexer import Lexer as tclingLexer
def main():
parser = tcLintParser(True)
tree = parser.parse("""puts hello
proc myProc {arg {arg7 0}} {}
set myVar 123
puts puts
LIB_SPF_prepend MOM_strt Start_Lib {
set somthing 1
set more 2
} myTag
LIB_SPF_prepend MOM_strt Start_Lib {
proc test {} {
puts "Hello"
}
set somthing 1
set someting 3
} myTag""")
print(tree.pretty(2))
def lexer_test():
lexer = tclingLexer()
tree = lexer.input("""
if {$oem(custom_clamp_4th) == 1 && $oem(custom_clamp_5th) == 1 \\
&& $oem(status_clamp_4th) == "off" && $oem(status_clamp_5th) == "off"}""")
# print("Lexing input:\n", code)
# print("\nTokens:\n" + "-" * 30)
while lexer.type() is not None:
tok_type = lexer.type()
tok_value = lexer.value()
tok_pos = lexer.pos()
print(f"Type: {tok_type:20} | Value: {repr(tok_value):20} | Pos: {tok_pos}")
lexer.next()
def test_1():
from tclint.lexer import Lexer, TOK_BACKSLASH_NEWLINE
code = "expr {1 == 2 \\\n&& 3 == 4}"
lexer = Lexer()
lexer.input(code)
while lexer.type() is not None:
print(
f"Type: {lexer.type():<20} | Value: {lexer.value()!r} | Pos: {lexer.pos()}"
)
lexer.next()
class NodeVisitor:
def visit_script(self, node):
for stmt in node.statements:
stmt.accept(self)
def visit_proc(self, node):
print(f"Proc: {node.name}, args={node.args}")
def visit_set(self, node):
print(f"Set: {node.varname} = {node.value}")
def visit_namespace(self, node):
print(f"Namespace: {node.name}")
def visit_command(self, node):
print(f"Command: {node.name} {node.args}")
if __name__ == "__main__":
test_1()