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:

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

  • jobiceprod.core.dataclasses.Job, optional

  • env – 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.