Remove obsolete work.py module, and accidental generation of b.xml diagnostic
authorNick Downing <nick@ndcode.org>
Sun, 27 Jan 2019 23:05:32 +0000 (10:05 +1100)
committerNick Downing <nick@ndcode.org>
Mon, 28 Jan 2019 10:24:00 +0000 (21:24 +1100)
lr1.py
lr1dfa.py
piyacc.py
work.py [deleted file]

diff --git a/lr1.py b/lr1.py
index 34bd7d0..7443419 100644 (file)
--- a/lr1.py
+++ b/lr1.py
@@ -18,7 +18,7 @@ import bisect
 import bisect_set
 import element
 import lr1dfa
-import work
+#import work
 import sys
 
 # defines the alphabet size, set this to 0x11000 for unicode
index c483be0..a403fb8 100644 (file)
--- a/lr1dfa.py
+++ b/lr1dfa.py
@@ -18,7 +18,7 @@ import bisect
 import bison_lr1dfa
 import element
 import numpy
-import work
+#import work
 import sys
 
 # defines the alphabet size, set this to 0x11000 for unicode
index fbf84d7..426bfbf 100755 (executable)
--- a/piyacc.py
+++ b/piyacc.py
@@ -77,8 +77,8 @@ with open(in_file) as fin:
 #element.serialize(_ast, 'a.xml', 'utf-8')
 #_ast = element.deserialize('a.xml', ast.factory, 'utf-8')
 _ast.post_process()
-element.serialize(_ast, 'b.xml', 'utf-8')
-_ast = element.deserialize('b.xml', ast.factory, 'utf-8')
+#element.serialize(_ast, 'b.xml', 'utf-8')
+#_ast = element.deserialize('b.xml', ast.factory, 'utf-8')
 (generate_py.generate_py if python else generate_bison.generate_bison)(
   _ast,
   _element,
diff --git a/work.py b/work.py
deleted file mode 100644 (file)
index 89ce115..0000000
--- a/work.py
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright (C) 2018 Nick Downing <nick@ndcode.org>
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free Software
-# Foundation; version 2.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
-import sys
-import element
-
-def yychunk_line(root, fin):
-  line = fin.readline()
-  while len(line):
-    element.set_text(root, -1, element.get_text(root, -1) + line)
-    yield
-    line = fin.readline()
-
-def yychunk_block(root, fin, count):
-  block = fin.read(count)
-  while len(block):
-    element.set_text(root, -1, element.get_text(root, -1) + line)
-    yield
-    block = fin.read(count)
-
-def replace_with_element(root, pos0, off0, pos1, off1, child):
-  if pos0 < 0:
-    pos0, off0 = element.to_start_relative(root, pos0, off0)
-  if pos1 < 0:
-    pos1, off1 = element.to_start_relative(root, pos1, off1)
-  count = pos1 - pos0
-  assert count >= 0
-
-  temp = element.get_text(root, pos1)
-  root[pos0:pos1] = [child]
-  element.set_text(root, pos0 + 1, temp[off1:])
-  if count != 0:
-    temp = element.get_text(root, pos0)
-  element.set_text(root, pos0, temp[:off0])
-
-def replace_with_text(root, mark, i, j, text):
-  (pos0, off0) = mark[i]
-  (pos1, off1) = mark[j]
-  count = pos1 - pos0
-  assert count >= 0
-
-  temp = element.get_tail(root, pos1)
-  del root[pos0 + 1:pos1 + 1]
-  element.set_tail(
-    root,
-    pos0,
-    element.get_tail(root, pos0)[:off0] + text + temp[off1:]
-  )
-
-  if j != i + 1:
-    mark[i + 1:j + 1] = [mark[j]]
-  k = i + 1
-  delta_pos = -count
-  delta_off = off0 + len(text) - off1
-  while k < len(mark):
-    (pos2, off2) = mark[k]
-    if pos2 > pos1:
-      break
-    mark[k] = (pos2 + delta_pos, off2 + delta_off)
-    k += 1
-  if delta_pos != 0:
-    while k < len(mark):
-      (pos2, off2) = mark[k]
-      mark[k] = (pos2 + delta_pos, off2)
-      k += 1
-
-def replace_with_content(root, mark, i, j, child):
-  text = element.get_tail(child, -1)
-  if len(child) == 0:
-    replace_with_text(root, mark, i, j, text)
-  else:
-    (pos0, off0) = mark[i]
-    (pos1, off1) = mark[j]
-    count = pos1 - pos0
-    assert count >= 0
-  
-    temp = element.get_tail(root, pos1)
-    root[pos0 + 1:pos1 + 1] = child[:]
-    tail = element.get_tail(root, pos0 + len(child))
-    element.set_tail(root, pos0 + len(child), tail + temp[off1:])
-    if count != 0:
-      temp = element.get_tail(root, pos0)
-    element.set_tail(root, pos0, temp[:off0] + text)
-  
-    if j != i + 1:
-      mark[i + 1:j + 1] = [mark[j]]
-    k = i + 1
-    delta_pos = len(child) - count
-    delta_off = len(tail) - off1
-    while k < len(mark):
-      (pos2, off2) = mark[k]
-      if pos2 > pos1:
-        break
-      mark[k] = (pos2 + delta_pos, off2 + delta_off)
-      k += 1
-    if delta_pos != 0:
-      while k < len(mark):
-        (pos2, off2) = mark[k]
-        mark[k] = (pos2 + delta_pos, off2)
-        k += 1
-
-def extract_element(root, mark, i, j, factory, *args, **kwargs):
-  (pos0, off0) = mark[i]
-  (pos1, off1) = mark[j]
-  count = pos1 - pos0
-  assert count >= 0
-
-  result = factory(*args, **kwargs)
-  result[:] = [i.copy() for i in root[pos0 + 1:pos1 + 1]]
-  tail = element.get_tail(root, pos1)
-  if count == 0:
-    element.set_tail(result, -1, tail[off0:off1])
-  else:
-    element.set_tail(result, count - 1, tail[:off1])
-    tail = element.get_tail(root, pos0)
-    element.set_tail(result, -1, tail[off0:])
-  return result
-
-def extract_text(root, mark, i, j):
-  (pos0, off0) = mark[i]
-  (pos1, off1) = mark[j]
-  #result = [element.get_tail(root, i) for i in range(pos0, pos1 + 1)]
-  #result[-1] = result[-1][:off1]
-  #result[0] = result[0][off0:]
-  #return ''.join(result)
-  assert pos1 == pos0
-  return element.get_tail(root, pos0)[off0:off1]
-
-def apply_markup(root, pos0, off0, pos1, off1, factory, *args, **kwargs):
-  if pos0 < 0:
-    pos0, off0 = element.to_start_relative(root, pos0, off0)
-  if pos1 < 0:
-    pos1, off1 = element.to_start_relative(root, pos1, off1)
-  count = pos1 - pos0
-  assert count >= 0
-
-  child = factory(*args, **kwargs)
-  child[:] = root[pos0:pos1]
-
-  tail = element.get_text(root, pos1)
-  # at present, if count > 0, child[-1] is shared with root[pos1 - 1],
-  # so we cannot change child[-1].tail until after the replacement
-  if count == 0:
-    replace_with_element(root, pos0, off0, pos1, off1, child)
-    element.set_text(child, 0, tail[off0:off1])
-  else:
-    temp = element.get_text(root, pos0)
-    replace_with_element(root, pos0, off0, pos1, off1, child)
-    element.set_text(child, count, tail[:off1])
-    element.set_text(child, 0, temp[off0:])
-  return child
-
-def dump(root, mark):
-  i = 0
-  pos = -1
-  result = ''
-  while True:
-    assert i >= len(mark) or mark[i][0] >= pos
-    tail = element.get_tail(root, pos) 
-    off = 0
-    while off < len(tail) or (i < len(mark) and mark[i][0] == pos):
-      end = len(tail) if i >= len(mark) or mark[i][0] != pos else mark[i][1]
-      if end > off:
-        result += tail[off:end].replace('\n', '(lf)').replace('\t', '(tab)')
-        off = end
-      if i < len(mark) and mark[i][0] == pos:
-        result += '({0:d})'.format(i)
-        i += 1
-    pos += 1
-    if pos >= len(root):
-      break
-    result += '({0:s}{1:d})'.format(root[pos].tag, pos)
-  assert i >= len(mark)
-  result += '(eof)'
-  sys.stdout.write('{0:s}\n'.format(result[-159:])) #79:]))
-  sys.stdout.flush()