mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Build an AST instead of compiling and decompiling
This doesn't currently work, though, it won't reformat anything
This commit is contained in:
parent
7901995bc7
commit
61dd2b83af
1 changed files with 10 additions and 4 deletions
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
|
|
||||||
import typing as T
|
import typing as T
|
||||||
import argparse, json, os, sys
|
import argparse, json, os, sys, re
|
||||||
|
|
||||||
from .errors import PrintableError, report_bug, MultipleErrors, CompilerBugError
|
from .errors import PrintableError, report_bug, MultipleErrors, CompilerBugError
|
||||||
from .gir import add_typelib_search_path
|
from .gir import add_typelib_search_path
|
||||||
|
@ -188,13 +188,19 @@ class BlueprintApp:
|
||||||
for warning in warnings:
|
for warning in warnings:
|
||||||
warning.pretty_print(file.name, data, stream=sys.stderr)
|
warning.pretty_print(file.name, data, stream=sys.stderr)
|
||||||
|
|
||||||
formatted = decompiler.decompile_string(xml)
|
tokens = tokenizer.tokenize(data)
|
||||||
|
|
||||||
if data != formatted:
|
tokenized_str = ""
|
||||||
|
for item in tokens:
|
||||||
|
tokenized_str += str(item)
|
||||||
|
|
||||||
|
print(tokenized_str)
|
||||||
|
|
||||||
|
if data != tokenized_str:
|
||||||
if not opts.check:
|
if not opts.check:
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
file.truncate()
|
file.truncate()
|
||||||
file.write(formatted)
|
file.write(tokenized_str)
|
||||||
|
|
||||||
formatted_files += 1
|
formatted_files += 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue