本文整理汇总了Python中lexer.Lexer.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Lexer.parse方法的具体用法?Python Lexer.parse怎么用?Python Lexer.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lexer.Lexer
的用法示例。
在下文中一共展示了Lexer.parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __instantiateMetric
# 需要导入模块: from lexer import Lexer [as 别名]
# 或者: from lexer.Lexer import parse [as 别名]
context['inFile'] = inFileName
# instantiate all the desired metric classes
metricInstance = __instantiateMetric( metricModules, context, runMetrics, metrics, pa )
cm = ComputeMetrics( metricInstance, context, runMetrics, metrics, pa, so, co )
# define lexographical scanner to use for this run
# later, this may vary with file and language.
lex = Lexer()
if not pa.quietSw:
print "=== File: %s ===" % inFileName
try:
lex.parse( inFileName ) # parse input file
metrics["numCharacters"] = len(lex.srcLines)
metrics["numLines"] = lex.lineCount # lines of code
metrics = cm( lex )
# if printing desired, output summary and desired metrics
# also, note that this preserves the order of the metrics desired
if not pa.quietSw:
__printSummary( od, context, runMetrics, metrics, pa )
for m,n in pa.includeMetrics:
if metricInstance[m]:
result = metricInstance[m].display()
if metrics.has_key(m):
metrics[m].append( result )