Meta-Language Parser¶
A recursive descent parser for the IceProd meta language. Most commonly used in IceProd dataset configurations to refer to other parts of the same configuration.
- class iceprod.core.parser.ExpParser[source]¶
Expression parsing class for parameter values.
Grammar Definition:
char := any unicode character other than $()[] word := char | char + word starter := $ scopeL := ( scopeR := ) bracketL := [ bracketR := ] symbol := starter | starter + word phrase := symbol + scopeL + sentence + scopeR lookup := word + bracketL + word + bracketR | phrase + bracketL + word + bracketR sentence := lookup | phrase | word | lookup + sentence | phrase + sentence | word + sentence
Keywords:
steering : A parameter from
iceprod.core.dataclasses.Steering
system : A system value from
iceprod.core.dataclasses.Steering
args, options : An option value from
iceprod.core.dataclasses.Job
metadata : A value from
iceprod.core.dataclasses.Dif
oriceprod.core.dataclasses.Plus
eval : An arithmatic expression
sum, min, max, len : Apply a reduction to a sequence
choice : A random choice from a list of possibilites
sprintf : The sprintf string syntax
Examples:
$steering(my_parameter) $system(gpu_opts) $args(option1) $options(option1) $metadata(sensor_name) $eval(1+2) $choice(1,2,3,4) $sprintf("%04d",4)
- parse(input, job=None, env=None, depth=20)[source]¶
Parse the input, expanding where possible.
- Parameters:
input – input string
job –
iceprod.core.dataclasses.Job
, optionalenv – env dictionary, optional
depth – how deep to recursively parse
- Returns:
expanded string
- classmethod safe_eval.eval(expr)[source]¶
Safe evaluation of arithmatic operations using
Abstract Syntax Trees
.