public TableConstructor(LuaParser.TableconstructorContext context, ScriptLoadingContext lcontext) : base(context, lcontext) { var fieldlist = context.fieldlist(); if (fieldlist != null) { foreach (var field in fieldlist.field()) { var keyval = field.keyexp; var name = field.NAME(); if (keyval != null) { Expression exp = NodeFactory.CreateExpression(keyval, lcontext); m_CtorArgs.Add(new KeyValuePair <Expression, Expression>( exp, NodeFactory.CreateExpression(field.keyedexp, lcontext))); } else if (name != null) { m_CtorArgs.Add(new KeyValuePair <Expression, Expression>( new LiteralExpression(field, lcontext, DynValue.NewString(name.GetText())), NodeFactory.CreateExpression(field.namedexp, lcontext))); } else { m_PositionalValues.Add(NodeFactory.CreateExpression(field.positionalexp, lcontext)); } } } }
/// <summary> /// Enter a parse tree produced by <see cref="LuaParser.tableconstructor" />. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public override void EnterTableconstructor(LuaParser.TableconstructorContext context) { var field = GetParentField(context); _currentScope++; switch (_currentScope) { case MMSavedVariableScope.AccountData: if (field != null) { CurrentAccountName = field.Name; } break; case MMSavedVariableScope.EsoItemBase: // Save the name of the base item scope field as the item id for all items within the scope. if (field != null) { _currentItemBaseId = field.Name; } break; case MMSavedVariableScope.EsoItem: // Instantiate new item variety if (string.IsNullOrEmpty(_currentItemBaseId) || field == null || string.IsNullOrEmpty(field.Name)) { CurrentItem = null; } else { CurrentItem = new EsoItem { BaseId = _currentItemBaseId, ItemIndex = field.Name }; _currentItemSales.Clear(); } break; case MMSavedVariableScope.EsoGuildStoreSale: if (CurrentItem == null) { CurrentSale = null; } else { CurrentSale = new EsoSale { Submitter = CurrentAccountName }; } break; } }
protected LuaTableField GetParentField(LuaParser.TableconstructorContext context) { if (!(context.Parent is LuaParser.ExpContext) || !(context.Parent.Parent is LuaParser.FieldContext)) { return(null); } return(GetField((LuaParser.FieldContext)context.Parent.Parent, (LuaParser.ExpContext)context.Parent)); }
/// <summary> /// Exit a parse tree produced by <see cref="LuaParser.tableconstructor" />. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public override void ExitTableconstructor(LuaParser.TableconstructorContext context) { switch (_currentScope) { case MMSavedVariableScope.EsoGuildStoreSale: // Exiting a sale scope if (CurrentSale != null) { _currentItemSales.Add(CurrentSale); } break; case MMSavedVariableScope.EsoItem: if (CurrentItem != null && _currentItemSales.Count > 0) { // Extract the item's name from the last sale's ItemLink property, since it's not stored in the item scope as a field. if (string.IsNullOrEmpty(CurrentItem.Name)) { EsoSale lastSale = _currentItemSales.Last(); CurrentItem.Name = lastSale.GetItemNameFromLink(); } // Report the sale. if (SaleFound != null) { foreach (var sale in _currentItemSales) { sale.Set(CurrentItem); SaleFound(this, new EsoGuildStoreSaleEventArgs { Sale = sale }); } } } break; } _currentScope--; }
public void ExitTableconstructor([NotNull] LuaParser.TableconstructorContext context) { throw new NotImplementedException(); }
public virtual void ExitTableconstructor([NotNull] LuaParser.TableconstructorContext context) { }
public virtual Result VisitTableconstructor([NotNull] LuaParser.TableconstructorContext context) { return(VisitChildren(context)); }
public void EnterTableconstructor([NotNull] LuaParser.TableconstructorContext context) => DefaultEnter(context);