7975b8cef9
This CL creates the "tools/torque" directory. It moves the existing two scripts (making the parser and formatting Torque code) into that director. The extension lives in "tools/torque/vscode-torque" and currently only provides basic syntax highlighting support. The easiest way to install the extension is to simply create a symlink into your local vscode extension directory (see README.md). R=jgruber@chromium.org, tebbi@chromium.org Change-Id: Ifc22b615341ed18f91c9b046090f569fcc083ab6 Reviewed-on: https://chromium-review.googlesource.com/1076548 Commit-Queue: Simon Zünd <szuend@google.com> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#53421}
37 lines
995 B
Python
Executable File
37 lines
995 B
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright 2014 the V8 project authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
"""This program either generates the parser files for Torque, generating
|
|
the source and header files directly in V8's src directory."""
|
|
|
|
import subprocess
|
|
import sys
|
|
import re
|
|
from subprocess import Popen, PIPE
|
|
|
|
if len(sys.argv) < 2 or len(sys.argv) > 3:
|
|
print "invalid number of arguments"
|
|
sys.exit(-1)
|
|
|
|
use_stdout = True
|
|
if len(sys.argv) == 3 and sys.argv[1] == '-i':
|
|
use_stdout = False
|
|
|
|
filename = sys.argv[len(sys.argv) - 1]
|
|
|
|
with open(filename, 'r') as content_file:
|
|
content = content_file.read()
|
|
p = Popen(['clang-format', '-assume-filename=.ts'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
output, err = p.communicate(content)
|
|
rc = p.returncode
|
|
if (rc <> 0):
|
|
sys.exit(rc);
|
|
if use_stdout:
|
|
print output
|
|
else:
|
|
output_file = open(filename, 'w')
|
|
output_file.write(output);
|
|
output_file.close()
|