Skip to content

Commit

Permalink
[mycpp] Minor fixes to translate examples/parse.py.
Browse files Browse the repository at this point in the history
It still doesn't compile.
  • Loading branch information
Andy Chu committed Apr 17, 2019
1 parent b5e0dc9 commit 32eda5e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions asdl/format.py
Expand Up @@ -267,7 +267,7 @@ def _PrintWholeArray(array, prefix_len, f, indent, max_col):
# The first child is out of line. The abbreviated objects have a
# small header like C or DQ so it doesn't matter as much.
all_fit = True
pieces = []
pieces = [] # type: List[Tuple[str, int]]
chars_so_far = prefix_len
for item in array:
single_f = f.NewTempBuffer()
Expand Down Expand Up @@ -453,7 +453,9 @@ def _TrySingleLine(node, # type: runtime._PrettyBase
return _TrySingleLineObj(node, f, max_chars)

else:
raise AssertionError("Unexpected node: %r (%r)" % (node, node.__class__))
raise AssertionError("Unexpected node: %r" % node)
# mycpp doesn't like __class__
#raise AssertionError("Unexpected node: %r (%r)" % (node, node.__class__))

# Take into account the last char.
num_chars_so_far = f.NumChars()
Expand Down
2 changes: 1 addition & 1 deletion mycpp/examples/parse.py
Expand Up @@ -182,7 +182,7 @@ def run_tests():
log('Parse error: %s', e.msg)
continue

log('%s', tree)
#log('%s', tree)

pretty_tree = tree.AbbreviatedTree()
#ast_f = fmt.TextOutput(sys.stdout)
Expand Down
8 changes: 4 additions & 4 deletions mycpp/run.sh
Expand Up @@ -302,7 +302,7 @@ compile-example() {

# Because it depends on ASDL
compile-parse() {
compile parse '' -I _gen
_compile-example parse '' -I _gen
}

run-python-example() {
Expand Down Expand Up @@ -374,7 +374,7 @@ benchmark-parse() {
should-skip() {
case $1 in
# not passing yet!
# parse needs asdl/format.py, and the other 3 are testing features it
# parse needs asdl/format.py, and the other 2 are testing features it
# uses.
parse|files|classes)
return 0
Expand Down Expand Up @@ -460,9 +460,9 @@ grepall() {
}

count() {
wc -l {mycpp,debug,cppgen,fib}.py
wc -l *.py | sort -n
echo
wc -l *.cc *.h
wc -l *.cc *.h | sort -n
}

cpp-compile-run() {
Expand Down

0 comments on commit 32eda5e

Please sign in to comment.