Commits

Robert Brewer committed af6853a

Renamed buildParser to getBuilder and tt_tuple to getParser

Comments (0)

Files changed (15)

-SimpleParse 2.0.0
-A Parser Generator for Python and mxTextTools
+SimpleParse 3.0.0a1
+A threadsafe Parser Generator for Python and mxTextTools
 
 See doc/index.html for installation instructions,
 release notes and user documentation.
 		name = "SimpleParse",
 		version = "3.0.0a1",
 		description = "A Parser Generator for Python (w/mxTextTools derivative)",
-		author = "Mike C. Fletcher",
-		author_email = "mcfletch@users.sourceforge.net",
-		url = "http://simpleparse.sourceforge.net/",
+		author = "Mike C. Fletcher, Robert E. Brewer",
+		author_email = "fumanchu@aminus.org",
+		url = "https://bitbucket.org/fumanchu/simpleparse",
 
 		package_dir = packages,
 		options = options,

simpleparse/common/comments.py

 _p = Parser( eolcomments )
 for name in ["hash_comment", "semicolon_comment", "slashslash_comment"]:
 	c[ name ] = objectgenerator.LibraryElement(
-		builder = _p._generator.buildParser(),
+		builder = _p._generator.getBuilder(),
 		production = name,
 	)
 
 _p = Parser( ccomments )
 for name in ["c_comment","slashbang_comment"]:
 	c[ name ] = objectgenerator.LibraryElement(
-		builder = _p._generator.buildParser(),
+		builder = _p._generator.getBuilder(),
 		production = "slashbang_comment",
 	)
 
 _p = Parser( nccomments )
 for name in ["c_nest_comment","slashbang_nest_comment"]:
 	c[ name ] = objectgenerator.LibraryElement(
-		builder = _p._generator.buildParser(),
+		builder = _p._generator.getBuilder(),
 		production = "slashbang_nest_comment",
 	)
 

simpleparse/common/iso_date.py

 _p = Parser( declaration )
 for name in ["ISO_time","ISO_date", "ISO_date_time"]:
 	c[ name ] = objectgenerator.LibraryElement(
-		generator = _p._generator,
+		builder = _p._generator.getBuilder(),
 		production = name,
 	)
 common.share( c )

simpleparse/common/iso_date_loose.py

 _p = Parser( declaration )
 for name in ["ISO_time_loose","ISO_date_time_loose", "ISO_date_loose"]:
 	c[ name ] = objectgenerator.LibraryElement(
-		generator = _p._generator,
+		builder = _p._generator.getBuilder(),
 		production = name,
 	)
 common.share( c )

simpleparse/common/numbers.py

 _p = Parser( declaration )
 for name in ["int","hex", "int_unsigned", "number", "float", "binary_number", "float_floatexp", "imaginary_number", "number_full"]:
 	c[ name ] = objectgenerator.LibraryElement(
-		builder = _p._generator.buildParser(),
+		builder = _p._generator.getBuilder(),
 		production = name,
 	)
 

simpleparse/common/strings.py

 for name, partial in _stringTypeData:
 	_p = Parser( stringDeclaration + partial )
 	c[ name ] = objectgenerator.LibraryElement(
-		builder = _p._generator.buildParser(),
+		builder = _p._generator.getBuilder(),
 		production = "str",
 	)
 common.share( c )
 string :=  string_triple_double/string_triple_single/string_double_quote/string_single_quote
 """ )
 c[ "string"] = objectgenerator.LibraryElement(
-	builder = _p._generator.buildParser(),
+	builder = _p._generator.getBuilder(),
 	production = "string",
 )
 

simpleparse/generator.py

 			self.rootObjects.append( rootElement )
 			return self.getNameIndex( name )
 
-	def buildParser( self, methodSource=None ):
-		'''Build the given parser definition, returning a Builder instance'''
+	def getBuilder( self, methodSource=None ):
+		'''Return a Builder instance for building parsers.'''
 		builder = Builder(self, methodSource)
-		builder.fill_terminals(self.rootObjects)
+		builder.fillTerminals(self.rootObjects)
 		return builder
 
 	def cacheCustomTerminalParser( self, index, flags, parser ):
 		self.parserList = []
 		self.methodSource = methodSource
 
-	def fill_terminals(self, rootObjects):
+	def fillTerminals(self, rootObjects):
 		# XXX Note: rootObjects will grow in certain cases where
 		# a grammar is loading secondary grammars into itself
 		for i, rootObject in enumerate(rootObjects):
 				raise
 		assert None not in self.parserList, str(self.parserList)
 
-	def tt_tuple(self, name):
+	def getParser(self, name):
 		"""Return a TextTools parsing tuple for the given name."""
 		return self.parserList [self.generator.getNameIndex(name)]
 
 
 ### Compatability API
 ##  This API exists to allow much of the code written with SimpleParse 1.0
-##  to work with SimpleParse 2.0
+##  to work with SimpleParse 2.0+
 class GeneratorAPI1:
 	"""Stand-in class supporting operation of SimpleParse 1.0 applications
 

simpleparse/objectgenerator.py

 			b = builder
 		else:
 			b = self.builder
-		basetable = b.tt_tuple(self.production)
+		basetable = b.getParser(self.production)
 		try:
 			if type(basetable[0]) == type(()):
 				if len(basetable) == 1 and len(basetable[0]) == 3:

simpleparse/parser.py

 			production = self._rootProduction
 		if processor is None:
 			processor = self.buildProcessor()
-		builder = self._generator.buildParser(methodSource=processor)
-		return builder.tt_tuple(production)
+		builder = self._generator.getBuilder(methodSource=processor)
+		return builder.getParser(production)
 	

simpleparse/printers.py

 	'''
 	def buildTagger( self, name=None, processor = None ):
 		'''Build the tag-table for parsing the EBNF for this parser'''
-		return GENERATOR.buildParser( processor ).tt_tuple(name)
+		return GENERATOR.getBuilder( processor ).getParser(name)
 
 """
 	ITEM = """GENERATOR.addDefinition(

simpleparse/simpleparsegrammar.py

 		self.generator = processor.generator
 	def buildTagger( self, name=None, processor = None ):
 		"""Build the tag-table for parsing the EBNF for this parser"""
-		return SPGenerator.buildParser( processor ).tt_tuple( name )
+		return SPGenerator.getBuilder( processor ).getParser( name )
 
 class SPGrammarProcessor( DispatchProcessor ):
 	"""Processing object for post-processing an EBNF into a new generator"""

tests/test_backup_on_subtable_failure.py

 import pprint
 
 
-parser = Parser( declaration ).generator.buildParser().tt_tuple('testparser')
+parser = Parser( declaration ).generator.getBuilder().getParser('testparser')
 result = TextTools.tag( testdata, parser )
 if result != expectedResult:
 	print 'backup-on-subtable-test failed'

tests/test_deep_nesting.py

 ], 4)
 
 
-parser = Parser( declaration ).generator.buildParser().tt_tuple( 'testparser' )
+parser = Parser( declaration ).generator.getBuilder().getParser( 'testparser' )
 print "About to attempt the deep-nesting test"
 print "If python goes into an infinite loop, then the test failed ;) "
 print

tests/test_grammarparser.py

 
 from simpleparse.stt.TextTools import print_tagtable
 print_tagtable(
-	SPGenerator.buildParser().tt_tuple('range')
+	SPGenerator.getBuilder().getParser('range')
 )
 
 
 class SimpleParseGrammarTests(unittest.TestCase):
 	"""Test parsing of the the simpleparse grammar elements"""
 	def doBasicTest(self, parserName, testValue, expected, ):
-		parser = SPGenerator.buildParser().tt_tuple(parserName)
+		parser = SPGenerator.getBuilder().getParser(parserName)
 		result = TextTools.tag( testValue, parser )
 		assert result == expected, '''\nexpected:%s\n     got:%s\n'''%( expected, result )
 
 		)
 	def testDeclarationSet2( self ):
 		'''Just tries to parse and sees that everything was parsed, doesn't predict the result'''
-		parser = SPGenerator.buildParser().tt_tuple( "declarationset" )
+		parser = SPGenerator.getBuilder().getParser( "declarationset" )
 		result = TextTools.tag( declaration, parser )
 		assert result[-1] == len(declaration), '''Didn't complete parse of the simpleparse declaration, only got %s chars, should have %s'''%(result[-1], len(declaration))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.