Ejemplo n.º 1
0
        /// <summary>
        /// index = "[", expr, [ ",", expr ], "]"
        /// </summary>
        /// <param name="parent">Parent node get index from</param>
        /// <returns></returns>
        public IdentifierNode ParseIndex()
        {
            // "["
              var lexem = GetLexem();
              SkipLexem();
              var index1 = ParseExpr();

              if (PeekLexem(LexemType.Comma))
              {
            SkipLexem();
            // ? ","
            // double index!
            var index2 = ParseExpr();

            // "]"
            if (!PeekLexem(LexemType.SquareClose)) Error(Resources.errSquareBracketExpected);
            SkipLexem(true);

            // look ahead: if "=" then assignment and break loop
            var node = new MatrixGetNode();
            node.Index1 = index1;
            node.Index2 = index2;
            node.Lexem = lexem;
            return node;
              }
              else
              {
            // "]"
            if (!PeekLexem(LexemType.SquareClose)) Error(Resources.errSquareBracketExpected);
            SkipLexem(true);

            var node = new ArrayGetNode();
            node.Index = index1;
            node.Lexem = lexem;
            return node;
              }
        }
Ejemplo n.º 2
0
 public ArraySetNode(ArrayGetNode node)
 {
     ExpressionPrefix = node.ExpressionPrefix;
       Index = node.Index;
 }