def nonterminals(symbols):
"""
Given a string containing a list of symbol names, return a list of
``Nonterminals`` constructed from those symbols.
:param symbols: The symbol name string. This string can be
delimited by either spaces or commas.
:type symbols: str
:return: A list of ``Nonterminals`` constructed from the symbol
names given in ``symbols``. The ``Nonterminals`` are sorted
in the same order as the symbols names.
:rtype: list(Nonterminal)
"""
if ',' in symbols: symbol_list = symbols.split(',')
else: symbol_list = symbols.split()
return [Nonterminal(s.strip()) for s in symbol_list]
grammar.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录