コード例 #1
0
 internal void InitArrayDecl(Token initToken, int? initSize)
 {
     if (initToken != null && initSize != null)
     {
         this.tokenType = initToken;
         this.size = (int)initSize;
     }
 }
コード例 #2
0
ファイル: ValidOperators.cs プロジェクト: donreamey/NireLang
 internal static bool IsOperator(Token op)
 {
     foreach (string inop in AllOperators)
     {
         if (op.Value.Equals(inop))
         {
             return true;
         }
     }
     return false;
 }
コード例 #3
0
        private Expr ParseIfCondition(Expr expr, Token lparen)
        {
            if (_expressionScopeStack.Peek() is IfDeclExpr)
            {
                expr = _expressionScopeStack.Peek();
            }
            else
            {
                expr = new IfDeclExpr();
                _expressionScopeStack.Push(expr);
            }
            if (lparen.Kind == ByteCodeIdentifiers.TokenCode.LParen)
            {
                ParseStatementExpression();
                this.boe.Push(this.BinaryExpression);
                ((IfDeclExpr)expr).AddCondition(this.BinaryExpression);
            }

            return expr;
        }
コード例 #4
0
 internal StringDeclExpr(Token var)
 {
     this.varName = var;
 }
コード例 #5
0
 internal StatementsSeqExpr(
     Token identifer,
     SequenceExpressionType type)
     : this()
 {
     identifier = identifer;
     sequenceType = type;
 }
コード例 #6
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;
        }
コード例 #7
0
ファイル: SyntaxTree.cs プロジェクト: donreamey/NireLang
 internal static LeafNode CreateLeafNode(Token token)
 {
     return null;
 }
コード例 #8
0
 internal BlockDeclExpr(
     Token returnType,
     Token name)
     : this()
 {
     functionReturnType = returnType;
     functionIdentifier = name;
 }
コード例 #9
0
ファイル: SyntaxTree.cs プロジェクト: donreamey/NireLang
 internal IntegerLeaf(Token t)
     : base(t)
 {
 }
コード例 #10
0
 internal IdentifierExpression(Token token)
     : this()
 {
     this.identifier = token;
 }
コード例 #11
0
            internal static ShiftReduceEval Validate(Token opOnStack, Token opInStream)
            {
                string s = (String)opOnStack.Value;
                string y = (String)opInStream.Value;

                OpValue? stackEnum = GetOpAsEnum(s);
                OpValue? streamEnum = GetOpAsEnum(y);

                return OperatorPrecedenceTable.ShiftReduceOperationTable[(int)stackEnum, (int)streamEnum];
            }
コード例 #12
0
 internal FunctionCallExpression(
     Token functionName)
     : this()
 {
     this.functionName = functionName.IdentiferName;
     this.identifier = functionName;
 }
コード例 #13
0
 internal FunctionDeclBlock(
     Token returnType,
     Token name)
     : base(returnType, name)
 {
 }
コード例 #14
0
 internal FunctionCallExpression(
     Token functionName,
     List<Expr> parameters)
     : this(functionName)
 {
     this.functionName = functionName.IdentiferName;
     this.listOfParameters = parameters;
 }
コード例 #15
0
 internal EndFunctionExpression(Token functionName)
     : this()
 {
     this.identifier = functionName;
 }
コード例 #16
0
 internal BlockDeclExpr(
     Token name)
     : this()
 {
     functionIdentifier = name;
 }
コード例 #17
0
 internal ArrayDeclExpr(Token tokenType, Token tokenIdentifier, int size)
     : this(tokenType, tokenIdentifier)
 {
     this.size = size;
 }
コード例 #18
0
ファイル: SyntaxTree.cs プロジェクト: donreamey/NireLang
 internal OperatorNode(Token operand)
     : base(operand)
 {
 }
コード例 #19
0
 internal IdentifierExpression(Token token, IdentifierExpression nested)
     : this(token)
 {
     this.nestedExpression = nested;
 }
コード例 #20
0
ファイル: Parser.cs プロジェクト: donreamey/NireLang
        /// <summary>
        /// Parse the signature of the function
        /// </summary>
        private void ParseFunctionSignature(
            Expr parentNode,
            Token functionName)
        {
            List<Expr> pll = null;
            functionName.Kind = ByteCodeIdentifiers.TokenCode.Function;

            Token paren = _scanner.GetToken();

            /*
            * If there are parameters
            * add them to the parameter list
            */
            if (paren.Value.Equals(constants.LEFTPAREN))
            {
                pll = ParseFunctionParameters();
            }

            if (pll != null && pll.Count > 0)
            {
                var progExpression = parentNode as BlockDeclExpr;
                if (progExpression != null)
                {
                    progExpression.Parameters = pll;
                }

                if (functionName.IdentiferName.Equals(constants.MAIN, StringComparison.OrdinalIgnoreCase))
                {
                    _isMain = true;
                    progExpression.IsMain = true;
                }
            }
        }
コード例 #21
0
 internal IntDeclExpr(Token var, Token op, Token expr)
     : base()
 {
     this.variableName = var;
     this.theOperator = op;
     this.assignmentExpression = expr;
 }
コード例 #22
0
 internal OperatorExpression(Token token)
     : this()
 {
     this.identifier = token;
     operationType = Arity.binary;
 }
コード例 #23
0
ファイル: SyntaxTree.cs プロジェクト: donreamey/NireLang
 internal IdentifierLeaf(Token identifier)
     : base(identifier)
 {
 }
コード例 #24
0
 internal ProgramDeclBlock(
     Token name)
     : base(name)
 {
 }
コード例 #25
0
ファイル: SyntaxTree.cs プロジェクト: donreamey/NireLang
 internal LeafNode(Token value)
     : base()
 {
     _value = value;
 }
コード例 #26
0
 internal void AddTokenToList(Token token)
 {
     if (token.Kind == ByteCodeIdentifiers.TokenCode.Program)
     {
         this.Name = token;
         this.tokenList.Add(token);
     }
 }
コード例 #27
0
 private Token ParseToRightBracket(Expr expr, Token bracket, BinaryOperatorExpression boe)
 {
     while (bracket.Kind != ByteCodeIdentifiers.TokenCode.RBracket)
     {
         ParseStatementExpression();
         ((IfDeclExpr)expr).AddStatementToCondition(boe, this.BinaryExpression);
         bracket = _scanner.GetToken();
     }
     return bracket;
 }
コード例 #28
0
 internal ArrayDeclExpr(Token tokenType, Token tokenIdentifier)
     : this()
 {
     this.tokenType = tokenType;
     this.tokenIdentifier = tokenIdentifier;
 }
コード例 #29
0
ファイル: scanner.cs プロジェクト: donreamey/NireLang
 internal void PutTokenBack(Token t)
 {
     _scanPointer -= ((string)t.Value).Length;
 }
コード例 #30
0
ファイル: Parser.cs プロジェクト: donreamey/NireLang
        private Expr ArrayDeclaration(Token tokenType)
        {
            ArrayDeclExpr ade = null;

            Token ident = _scanner.GetToken();

            if (ParserContext.Context != ParserContextEnum.FunctionDecl)
            {
                if (ident.Kind != ByteCodeIdentifiers.TokenCode.Number)
                {
                    throw new NireExecutionException("array declaration did not contain a number");
                }

                var number = _scanner.GetToken();
                if (number.Kind != ByteCodeIdentifiers.TokenCode.Number || number.Kind != ByteCodeIdentifiers.TokenCode.Identifier)
                {
                    throw new NireExecutionException("not a valid array declaration");
                }

                var rb = _scanner.GetToken();

                //rbracket("]", "Not a valid array declaration");

                ade = new ArrayDeclExpr(tokenType, ident, Convert.ToInt32(ident.Value));
                return ade;
            }

            ade = new ArrayDeclExpr(tokenType, ident);

            return ade;
        }