示例#1
0
            override public Boolean TryParse(Context Context, Tokenizer.Token Token)
            {
                ClearState();
                Boolean _Ret = true;

                if (Token.GetTopNodeType().Equals(typeof(Tokenizer.RuleComment)))
                {
                    this.m_StartPos = Token.GetPosStart();
                    this.m_Length   = Token.GetPosEnd() - Token.GetPosStart();
                    m_Comment       = Token.GetValue(false);
                    return(_Ret);
                }
                else
                {
                    return(false);
                }
            }
示例#2
0
            override public Boolean TryParse(Context Context, Tokenizer.Token Token)
            {
                ClearState();
                Boolean _Ret = true;

                if (Token.GetTopNodeType().Equals(typeof(Tokenizer.RuleParamDecl)) ||
                    Token.GetTopNodeType().Equals(typeof(Tokenizer.RuleDecl)) ||
                    Context.m_ActualCmd.Equals(typeof(Tokenizer.RuleDecl)) ||
                    Token.GetTopNodeType().Equals(typeof(Tokenizer.RuleRetDecl)))
                {
                    if (Token.GetNodeType().Equals(typeof(Tokenizer.RuleBaseType)))
                    {
                        this.m_Type     = Token.GetValue(false);
                        this.m_StartPos = Token.GetPosStart();
                        this.m_Length   = Token.GetPosEnd() - Token.GetPosStart();
                    }
                    LinkedList <Tokenizer.Token> .Enumerator m_Subs = Token.GetEnumerator();
                    while (m_Subs.MoveNext())
                    {
                        if (m_Subs.Current.GetNodeType().Equals(typeof(Tokenizer.RuleBaseType)))
                        {
                            this.m_Type     = m_Subs.Current.GetValue(false);
                            this.m_StartPos = m_Subs.Current.GetPosStart();
                            this.m_Length   = m_Subs.Current.GetPosEnd() - m_Subs.Current.GetPosStart();
                        }
                        if (m_Subs.Current.GetNodeType().Equals(typeof(Tokenizer.RuleName)))
                        {
                            this.m_Name = m_Subs.Current.GetValue(false);
                            break;
                        }
                        this.m_Length = m_Subs.Current.GetPosEnd() - Token.GetPosStart();
                    }
                    if (this.m_Name.Equals("") && !Token.GetTopNodeType().Equals(typeof(Tokenizer.RuleRetDecl)))
                    {
                        this.m_Error += " missing name";
                    }
                    //Todo missing name

                    return(_Ret);
                }
                else
                {
                    return(false);
                }
            }
示例#3
0
            override public Boolean TryParse(Context Context, Tokenizer.Token Token)
            {
                ClearState();
                Boolean _Ret = true;

                if (Token.GetTopNodeType().Equals(typeof(Tokenizer.RuleUsing)))
                {
                    LinkedList <Tokenizer.Token> .Enumerator m_Subs = Token.GetEnumerator();
                    this.m_StartPos = Token.GetPosStart();
                    this.m_Length   = Token.GetPosEnd() - Token.GetPosStart();
                    while (m_Subs.MoveNext())
                    {
                        if (m_Subs.Current.GetNodeType().Equals(typeof(Tokenizer.RuleString)))
                        {
                            this.m_Path = m_Subs.Current.GetValue(false);
                            m_Path      = m_Path.Replace("\"", "");
                            //"UserMgr.lvlibp:UserManager.lvclass"   -> Name=UserManager
                            //"UserMgr.lvlibp"   -> Name=UserMgr
                            Match m = m_RegEx.Match(this.m_Path, 0);
                            if (m.Success && m.Groups.Count == 5)
                            {
                                this.m_Name = m.Groups[3].Value;
                            }
                            else
                            {
                                m = m_RegEx2.Match(this.m_Path, 0);
                                if (m.Success && m.Groups.Count == 3)
                                {
                                    this.m_Name = m.Groups[1].Value;
                                }
                                else
                                {
                                    this.m_Error += " invalid Path";
                                }
                            }
                        }
                        if (m_Subs.Current.GetNodeType().Equals(typeof(Tokenizer.RuleUsing)))
                        {
                            Tokenizer.Token AS = m_Subs.Current.First.Value;
                            if (AS.GetNodeType().Equals(typeof(Tokenizer.RuleName)))
                            {
                                this.m_Name = AS.GetValue(false);
                            }
                        }
                        if (m_Subs.Current.GetNodeType().Equals(typeof(Tokenizer.RuleName)))    //optional Name is hidden behind "as"
                        {
                            this.m_Name = m_Subs.Current.First.Value.GetValue(false);
                        }
                        this.m_Length = m_Subs.Current.GetPosEnd() - Token.GetPosStart();
                    }

                    if (this.m_Path.Equals(""))
                    {
                        this.m_Error += " missing path";
                    }

                    return(_Ret);
                }
                else
                {
                    return(false);
                }
            }
示例#4
0
 /// <summary>
 /// returns true if the token was successfully converted to Cmd
 /// even if there are errors in the cmd
 /// </summary>
 /// <param name="Context"></param>
 /// <param name="Token"></param>
 /// <returns></returns>
 override public Boolean TryParse(Context Context, Tokenizer.Token Token)
 {
     ClearState();
     this.m_Error = "unknown Cmd " + Token.GetValue(true);
     return(true);
 }