public Node ListType() { var result = new ListType() { AnchorToken = Expect(TokenCategory.LIST) }; Expect(TokenCategory.OF); result.Add(new ChimeraType() { AnchorToken = SimpleType() }); return(result); }
private void GetType(string SelectedSeries) { if (!string.IsNullOrWhiteSpace(SelectedSeries)) { listType = new ObservableCollection <string>(); DataTable dtSeries = bll.GetOutdoorTypeBySeries(SelectedSeries); //foreach (DataRow typeRow in dtSeries.Rows) //{ // ListType.Add(typeRow.ItemArray[0].ToString()); // // GetPower(typeRow.ItemArray[0].ToString()); //} if (dtSeries != null && dtSeries.Rows.Count > 0) { ListType.Add(CommonBLL.StringConversion(dtSeries.Rows[0].ItemArray[0])); ProductType = CommonBLL.StringConversion(dtSeries.Rows[0].ItemArray[1]); GetPower(CommonBLL.StringConversion(dtSeries.Rows[0].ItemArray[0])); } } }
/// listType parses a list type and returns a ListType AST private ListType ListType() { try { // we assume that the currently scanned token is a LBRACK var l = new ListType { Lbrack = tok.Pos, }; var needComma = false; for (;;) { var tok = Scan(); if (needComma) { if (tok.Type == TokenType.COMMA || tok.Type == TokenType.RBRACK) { // Do nothing } else { throw new PosErrorException(tok.Pos, $"error parsing list, expected comma or list end, got: {tok.Type}"); } } if (tok.Type == TokenType.BOOL || tok.Type == TokenType.NUMBER || tok.Type == TokenType.FLOAT || tok.Type == TokenType.STRING || tok.Type == TokenType.HEREDOC) { var node = LiteralType(); // If there is a lead comment, apply it if (leadComment != null) { node.LeadComment = leadComment; leadComment = null; } l.Add(node); needComma = true; } else if (tok.Type == TokenType.COMMA) { // get next list item or we are at the end // do a look-ahead for line comment Scan(); if (lineComment != null && l.List.Length > 0) { var lit = l.List[l.List.Length - 1] as LiteralType; if (lit != null) { lit.LineComment = lineComment; l.List[l.List.Length - 1] = lit; lineComment = null; } } Unscan(); needComma = false; continue; } else if (tok.Type == TokenType.LBRACE) { // Looks like a nested object, so parse it out ObjectType node; try { node = ObjectType(); } catch (Exception ex) { throw new PosErrorException(tok.Pos, "error while trying to parse object within list", ex); } l.Add(node); needComma = true; } else if (tok.Type == TokenType.LBRACK) { ListType node; try { node = ListType(); } catch (Exception ex) { throw new PosErrorException(tok.Pos, "error while trying to parse list within list", ex); } l.Add(node); } else if (tok.Type == TokenType.RBRACK) { // finished l.Rbrack = tok.Pos; return(l); } else { throw new PosErrorException(tok.Pos, $"unexpected token while parsing list: {tok.Type}"); } } } finally { //defer un(trace(p, "ParseListType")) } }