Esempio n. 1
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. 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.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);
        }