Example #1
0
        // TODO: dokončiť!
        // zostupne podľa priority vyhľadávania
        // konštanty sa pridružujú k iným operandom a určujú sa podľa kontextu!

        // "string"
        // "string".member
        // "string"[i]

        // &"FILE_LOCALIZED_STRING"

        // 56 | -56 | +56

        // []

        // { 1, 2, 3 }

        // (0,1,2)
        // (0,1,2)[i]

        // (subExpression)
        // (subExpression).member
        // (subExpression)[i]

        // true
        // false
        // undefined

        // thread

        // ::func
        // path::func | path::const

        // var | const
        // var.member
        // var[i]


        // as operators

        // = Expression

        // lastOperand [[delegate]]()
        // lastOperand [[delegate]]().member
        // lastOperand [[delegate]]()[i]

        // lastOperand func()
        // lastOperand func().member
        // lastOperand func()[i]
        // lastOperand path::func()
        // lastOperand path::func().member
        // lastOperand path::func()[i]

        public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo, ref bool isSingleOperand, bool isArrayContentDefEnabled, bool isArrayDefEnabled)
        {
            if ((isArrayDefEnabled && (ArrayDef.Check(parentInfo, parsingInfo, scriptInfo))) || // []
                (isArrayContentDefEnabled && ArrayContentDef.Check(parentInfo, parsingInfo, scriptInfo)))    // { 0,1,2 }
            {
                isSingleOperand = IsSingle(parentInfo, parsingInfo);
                return(true);
            }

            if (StringArray.Check(parentInfo, parsingInfo, scriptInfo) || // "str" | "str".member | "str"[]
                LocalizedString.Check(parentInfo, parsingInfo, scriptInfo) || // &"str"
                SignedNumber.Check(parentInfo, parsingInfo, scriptInfo) || // 56 | -56 | +56
                Vector.Check(parentInfo, parsingInfo, scriptInfo) || // (0,1,2) | (0,1,2)[]
                SubExpression.Check(parentInfo, parsingInfo, scriptInfo) || // (exp) | (exp).member* | (exp)[]*
                Literal.Check(parentInfo, parsingInfo, scriptInfo) || // true | false | undefined
                FuncCallModifier.Check(parentInfo, parsingInfo, scriptInfo) || // thread
                DelegateCall.Check(parentInfo, parsingInfo, scriptInfo) || // // [[delegate]](funcArgs) | [[d]]().member* | [[d]]()[]*
                FuncCall.Check(parentInfo, parsingInfo, scriptInfo) || // f() | path::f() | f().member* | f()[i]*
                DelegateDef.Check(parentInfo, parsingInfo, scriptInfo) || // ::func | path::func
                VarName.Check(parentInfo, parsingInfo, scriptInfo)    // var | var.member* | var[i]*
                )
            {
                isSingleOperand = IsSingle(parentInfo, parsingInfo);
                return(true);
            }

            return(false);
        }
Example #2
0
        private static void ParseExtern(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            DelegateDef delegDef = new DelegateDef();

            MoveInfo moveInfo = new MoveInfo(parentInfo);
            Path     path     = Path.Parse(moveInfo, parsingInfo, scriptInfo);

            if (path == null)
            {
                throw new SyntaxException("Bad path", parentInfo.GetErrorInfo());
            }

            delegDef._pathOrUsing = path.ToString();
            delegDef._pathElem    = path;

            // ::
            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            delegDef._nameSpaceElem = (Token)moveInfo.Current;

            // name
            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            delegDef._name = moveInfo.Current.ToString();

            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            delegDef.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, delegDef);
        }
Example #3
0
        private static void ParseLocal(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            DelegateDef delegDef = new DelegateDef();

            MoveInfo moveInfo = new MoveInfo(parentInfo);

            delegDef._nameSpaceElem = (Token)moveInfo.Current;

            moveInfo.FindNextBlack(SearchDirection.LeftToRight); // jump behind ::
            delegDef._name = moveInfo.Current.ToString();

            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            delegDef.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, delegDef);
        }
Example #4
0
        public override IElement CreateCopy()
        {
            DelegateDef e = new DelegateDef();

            e.AddChildren(this.CopyChildren());

            e._funcInfo = _funcInfo;

            e._name        = _name;
            e._pathOrUsing = _pathOrUsing;
            e._path        = _path;

            //e._pathElem = (Path)e.children[this.children.IndexOf(_pathElem)];
            e._nameSpaceElem = (Token)e.children[this.children.IndexOf(_nameSpaceElem)];

            return(e);
        }