aboutsummaryrefslogtreecommitdiff
path: root/exyapps/parsetree.py
diff options
context:
space:
mode:
authorsienkiew <sienkiew@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2011-09-27 13:33:55 -0400
committersienkiew <sienkiew@d34015c8-bcbb-4646-8ac8-8ba5febf221d>2011-09-27 13:33:55 -0400
commit952032bc3b5a1b0fc215b677ca1aa32385ba525b (patch)
tree16d513b8a87c86322d5b80e60ba33600da0f6dd7 /exyapps/parsetree.py
parent2402b5a9be840e39749a245fea2a516da38a6f64 (diff)
downloadexyapps-952032bc3b5a1b0fc215b677ca1aa32385ba525b.tar.gz
various explanatory text
version number in __version__ AURA copyrights remove code to support importing runtime instead of incorporating it into the generated parser add MANIFEST.in instructions for re-generating the parser that exyapps uses internally git-svn-id: http://svn.stsci.edu/svn/ssb/etal/exyapps/trunk@431 d34015c8-bcbb-4646-8ac8-8ba5febf221d
Diffstat (limited to 'exyapps/parsetree.py')
-rw-r--r--exyapps/parsetree.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/exyapps/parsetree.py b/exyapps/parsetree.py
index 5e38665..964a74e 100644
--- a/exyapps/parsetree.py
+++ b/exyapps/parsetree.py
@@ -1,12 +1,16 @@
-# parsetree.py, part of Yapps 2 - yet another python parser system
+# parsetree.py, part of exyapps
# Copyright 1999-2003 by Amit J. Patel <amitp@cs.stanford.edu>
+# Copyright 2011 by Association of Universities for Research in Astronomy
#
-# This version of the Yapps 2 Runtime can be distributed under the
-# terms of the MIT open source license, either found in the LICENSE file
-# included with the Yapps distribution
-# <http://theory.stanford.edu/~amitp/yapps/> or at
+# This software can be distributed under the terms of the MIT
+# open source license, either found in the LICENSE file or at
# <http://www.opensource.org/licenses/mit-license.php>
#
+# -----
+#
+# Except for changes necessary to incorporate the runtime library directly
+# into the generated parser, this file is not substantially changed from
+# YAPPS 2.
"""Classes used to represent parse trees and generate output.
@@ -15,14 +19,16 @@ of Python output from a grammar parse tree. It also defines nodes
used to represent the parse tree; they are derived from class Node.
The main logic of Yapps is in this module.
+
+This module is used only to compile a parser.
"""
import sys, re
import os.path
-# load the contents of the runtime file into memory; it will be
-# incorporated into the parser later.
+# Load the contents of the runtime file into memory. We always need
+# this. It will be incorporated into the generated parser code later.
runtime_py_filename = os.path.dirname(__file__)+"/runtime.py"
f = open( runtime_py_filename ,"r")
runtime_contents = f.read()
@@ -42,7 +48,6 @@ class Generator:
self.options = options
self.preparser = ''
self.postparser = None
- self.inline_runtime = 1
self.tokens = {} # Map from tokens to regexps
self.ignore = {} # List of token names to ignore in parsing, map to statements
@@ -286,12 +291,9 @@ class Generator:
self.write("import sys, re\n")
#
- if self.inline_runtime :
- self.write("###### included from %s\n"%runtime_py_filename)
- self.write(runtime_contents)
- self.write("###### end of runtime.py\n")
- else :
- self.write("from exyapps.runtime import SyntaxError, NoMoreTokens, Token, Scanner, Parser, Context, print_error, wrap_error_reporter\n")
+ self.write("###### included from %s\n"%runtime_py_filename)
+ self.write(runtime_contents)
+ self.write("###### end of runtime.py\n")
self.write("\n")