/// <summary> /// Push a spice property on the value stack. /// </summary> /// <param name="property">The Spice property.</param> protected override void PushSpiceProperty(SpiceProperty property) { var args = new ExpressionTreeSpicePropertyEventArgs(property); SpicePropertyFound?.Invoke(this, args); if (args.Result == null) { throw new ParserException("Unrecognized Spice property '{0}'".FormatString(property), Input, Index); } _stack.Push(args.Result); }
/// <summary> /// Constructor /// </summary> /// <param name="property">The property.</param> public SimpleDerivativePropertyEventArgs(SpiceProperty property) : base(property) { Result = null; }
/// <summary> /// Parse a value. /// </summary> /// <returns> /// <c>true</c> if a value was parsed; otherwise, <c>false</c>. /// </returns> protected override bool ParseValue() { // Try to find a number if (ParseDouble(out var value)) { PushValue(value); return(true); } SpiceProperty args; string arg; switch (Input[Index]) { case 'v': case 'V': if (NextChar() == '(') { string id = Input[Index].ToString(); Index += 2; arg = NextUntil(')'); var properties = arg.Split(','); if (TrimNames) { for (var i = 0; i < properties.Length; i++) { properties[i] = properties[i].Trim(); } } args = new SpiceProperty(id, properties); Index += arg.Length + 1; PushSpiceProperty(args); return(true); } break; case 'i': case 'I': if (NextChar() == '(') { string id = Input[Index].ToString(); Index += 2; arg = NextUntil(')'); Index += arg.Length + 1; var properties = arg.Split(','); if (TrimNames) { for (var i = 0; i < properties.Length; i++) { properties[i] = properties[i].Trim(); } } args = new SpiceProperty(id, properties); PushSpiceProperty(args); return(true); } break; case '@': Index++; var name = NextUntil('['); Index += name.Length + 1; arg = NextUntil(']'); Index += arg.Length + 1; if (TrimNames) { name = name.Trim(); arg = arg.Trim(); } args = new SpiceProperty("@", name, arg); PushSpiceProperty(args); return(true); } // Try parsing variables or Spice properties if (base.ParseValue()) { return(true); } return(false); }
/// <summary> /// Push a spice property on the value stack. /// </summary> /// <param name="property">The Spice property.</param> protected abstract void PushSpiceProperty(SpiceProperty property);
/// <summary> /// Initializes a new instance of the <see cref="ExpressionTreeSpicePropertyEventArgs"/>. /// </summary> /// <param name="property"></param> public ExpressionTreeSpicePropertyEventArgs(SpiceProperty property) : base(property) { }
/// <summary> /// Constructor /// </summary> /// <param name="property">The property.</param> public ExpressionTreeDerivativePropertyEventArgs(SpiceProperty property) : base(property) { Result = null; }
/// <summary> /// Constructor /// </summary> /// <param name="property">The Spice property.</param> public SpicePropertyFoundEventArgs(SpiceProperty property) { Property = property.ThrowIfNull(nameof(property)); }