コード例 #1
0
ファイル: Parser.cs プロジェクト: donreamey/NireLang
        private void ParseIntDeclaration(out Expr expr)
        {
            Token ident = _scanner.GetToken();
            if (ident.Kind == ByteCodeIdentifiers.TokenCode.SquareBracketLeft)
            {

            }
            else
            {
                ident = _scanner.GetToken();
            }

            expr = new IdentifierExpression(ident);
        }
コード例 #2
0
 internal IdentifierExpression(Token token, IdentifierExpression nested)
     : this(token)
 {
     this.nestedExpression = nested;
 }
コード例 #3
0
ファイル: Parser.cs プロジェクト: donreamey/NireLang
        private IdentifierExpression DetermineNextToken(Token t)
        {
            if (t != null && t.IsReserverdWord())
            {
                Token next = _scanner.GetToken();
                Expr currentScope = null;

                if (_expressionScopeStack.Count > 0)
                {
                    currentScope = _expressionScopeStack.Peek();
                }

                if (next.IsReserverdWord())
                {
                    throw new NireExecutionException("a reserverd word cannot be used in the expression");
                }

                if (next.IsIdentifier() && !next.isOperator)
                {
                    var identExpression = new IdentifierExpression(t, new IdentifierExpression(next));
                    SymbolTable.CreateInstance().AddTokenToScope(currentScope, identExpression);
                    return identExpression;
                }
            }
            else
            {
                var isParen = _scanner.Peek();
                if (isParen.Kind == ByteCodeIdentifiers.TokenCode.LParen)
                {
                    new ParserContext(ParserContextEnum.FuncExecution);
                    //_scanner.GetToken();
                }

                Expr defaultScope = _expressionScopeStack.Peek();
                var funcExpression = new IdentifierExpression(t);
                SymbolTable.CreateInstance().AddTokenToScope(defaultScope, funcExpression);
                return funcExpression;
            }

            return null;
        }