Esempio n. 1
0
        public SimpleRecResult GetGenericParams(CompilerState State, ref CodeString Code,
                                                out CodeString[] Out, bool EnableMessages = true)
        {
            Out = null;
            if (Code.Length > 0 && Code[Code.Length - 1] == '>')
            {
                var BracketPos = Code.GetBracketPos(State, true);
                if (BracketPos == -1)
                {
                    return(SimpleRecResult.Failed);
                }

                var ParamStart = BracketPos + 1;
                var StrParams  = Code.TrimmedSubstring(State, ParamStart, Code.Length - ParamStart - 1);
                if (!StrParams.IsValid)
                {
                    return(SimpleRecResult.Failed);
                }

                Out = RecognizerHelper.GetParamList(State, StrParams);
                if (Out == null)
                {
                    return(SimpleRecResult.Failed);
                }

                Code = Code.Substring(0, BracketPos).Trim();
            }

            return(SimpleRecResult.Unknown);
        }
Esempio n. 2
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            var        State = Container.State;
            CodeString Inside, Cutted;

            var Result = RecognizerHelper.ExtractBracket(State, String, '(', ref Code, out Inside, out Cutted);

            if (Result == SimpleRecResult.Succeeded)
            {
                var Params = RecognizerHelper.GetParamList(State, Inside, 1);
                if (Params == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var Node = Constants.CreateCStrNode(Container, Params[0]);
                if (Node == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var AsmName = Node.String;
                if (string.IsNullOrEmpty(AsmName))
                {
                    State.Messages.Add(MessageId.DeficientExpr, Params[0]);
                    return(SimpleRecResult.Failed);
                }

                for (var i = 0; i < Out.Count; i++)
                {
                    if (Out[i] is AssemblyNameModifier)
                    {
                        State.Messages.Add(MessageId.NotExpected, Cutted);
                        return(SimpleRecResult.Failed);
                    }
                }

                Out.Add(new AssemblyNameModifier(Cutted, AsmName));
                return(SimpleRecResult.Succeeded);
            }

            return(Result);
        }
Esempio n. 3
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            var        State = Container.State;
            CodeString Inside, Cutted;

            var Result = RecognizerHelper.ExtractBracket(State, String, '(', ref Code, out Inside, out Cutted);

            if (Result == SimpleRecResult.Succeeded)
            {
                var Params = RecognizerHelper.GetParamList(State, Inside, 1);
                if (Params == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var Node = Constants.CreateCIntNode(Container, Params[0]);
                if (Node == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var Align = (int)Node.Integer;
                if (!DataStoring.VerifyAlign(Align))
                {
                    State.Messages.Add(MessageId.InvalidAlign, Cutted);
                    return(SimpleRecResult.Failed);
                }

                for (var i = 0; i < Out.Count; i++)
                {
                    if (Out[i] is AlignModifier)
                    {
                        State.Messages.Add(MessageId.NotExpected, Cutted);
                        return(SimpleRecResult.Failed);
                    }
                }

                Out.Add(new AlignModifier(Cutted, Align));
                return(SimpleRecResult.Succeeded);
            }

            return(Result);
        }