aboutsummaryrefslogtreecommitdiff
path: root/exyapps
diff options
context:
space:
mode:
Diffstat (limited to 'exyapps')
-rw-r--r--exyapps/__init__.py2
-rwxr-xr-xexyapps/main.py10
-rw-r--r--exyapps/parsetree.py30
-rw-r--r--exyapps/runtime.py20
4 files changed, 36 insertions, 26 deletions
diff --git a/exyapps/__init__.py b/exyapps/__init__.py
index 1bb8bf6..eee103e 100644
--- a/exyapps/__init__.py
+++ b/exyapps/__init__.py
@@ -1 +1 @@
-# empty
+__version__ = '3.0dev'
diff --git a/exyapps/main.py b/exyapps/main.py
index 322a3eb..61f3478 100755
--- a/exyapps/main.py
+++ b/exyapps/main.py
@@ -1,15 +1,13 @@
#!/usr/bin/python
#
-# Yapps 2 - yet another python parser system
+# exyapps - yet another python parser system
# Copyright 1999-2003 by Amit J. Patel <amitp@cs.stanford.edu>
+# Copyright 2011 by Association of Universities for Research in Astronomy
#
-# This version of Yapps 2 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>
-#
import sys, re
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")
diff --git a/exyapps/runtime.py b/exyapps/runtime.py
index bcbf253..6c984b8 100644
--- a/exyapps/runtime.py
+++ b/exyapps/runtime.py
@@ -1,13 +1,23 @@
-# Yapps 2 Runtime, part of Yapps 2 - yet another python parser system
+# exyapps - yet another python parser system
# Copyright 1999-2003 by Amit J. Patel <amitp@cs.stanford.edu>
# Enhancements copyright 2003-2004 by Matthias Urlichs <smurf@debian.org>
+# 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>
#
+# -----
+#
+# Changes from the debian version:
+# - indented with spaces, not tabs
+# - when you instantiate the parser object, you can pass in an object
+# data=XXX that will be available to the parser as self.data; this
+# is basically a hook to provide parser-global data.
+#
+# Note that this file is incorporated directly into the generated parser.
+# Take care when defining new file-global names because the generated
+# parser has its own globals.
"""Run time libraries needed to run parsers generated by Yapps.