<s> from graphite . thirdparty . pyparsing import * <EOL> ParserElement . enablePackrat ( ) <EOL> grammar = Forward ( ) <EOL> expression = Forward ( ) <EOL> intNumber = Combine ( <EOL> Optional ( '<STR_LIT:->' ) + Word ( nums ) <EOL> ) ( '<STR_LIT>' ) <EOL> floatNumber = Combine ( <EOL> Optional ( '<STR_LIT:->' ) + Word ( nums ) + Literal ( '<STR_LIT:.>' ) + Word ( nums ) <EOL> ) ( '<STR_LIT:float>' ) <EOL> aString = quotedString ( '<STR_LIT:string>' ) <EOL> afterNumber = FollowedBy ( "<STR_LIT:U+002C>" ) ^ FollowedBy ( "<STR_LIT:)>" ) ^ FollowedBy ( LineEnd ( ) ) <EOL> number = Group ( <EOL> ( floatNumber + afterNumber ) | <EOL> ( intNumber + afterNumber ) <EOL> ) ( '<STR_LIT>' ) <EOL> boolean = Group ( <EOL> CaselessKeyword ( "<STR_LIT:true>" ) | <EOL> CaselessKeyword ( "<STR_LIT:false>" ) <EOL> ) ( '<STR_LIT>' ) <EOL> arg = Group ( <EOL> boolean | <EOL> number | <EOL> aString | <EOL> expression <EOL> ) <EOL> args = delimitedList ( arg ) ( '<STR_LIT:args>' ) <EOL> func = Word ( alphas + '<STR_LIT:_>' , alphanums + '<STR_LIT:_>' ) ( '<STR_LIT>' ) <EOL> call = Group ( <EOL> func + Literal ( '<STR_LIT:(>' ) . suppress ( ) + <EOL> args + Literal ( '<STR_LIT:)>' ) . suppress ( ) <EOL> ) ( '<STR_LIT>' ) <EOL> validMetricChars = alphanums + r'''<STR_LIT>''' <EOL> pathExpression = Combine ( <EOL> Optional ( Word ( validMetricChars ) ) + <EOL> Combine ( <EOL> ZeroOrMore ( <EOL> Group ( <EOL> Literal ( '<STR_LIT:{>' ) + <EOL> Word ( validMetricChars + '<STR_LIT:U+002C>' ) + <EOL> Literal ( '<STR_LIT:}>' ) + Optional ( Word ( validMetricChars ) ) <EOL> ) <EOL> ) <EOL> ) <EOL> ) ( '<STR_LIT>' ) <EOL> expression << Group ( call | pathExpression ) ( '<STR_LIT>' ) <EOL> grammar << expression <EOL> def enableDebug ( ) : <EOL> for name , obj in globals ( ) . items ( ) : <EOL> try : <EOL> obj . setName ( name ) <EOL> obj . setDebug ( True ) <EOL> except : <EOL> pass </s>
