internal DepsName ParseName()
        {
            JumpWhite();
            if (Current != '.')
            {
                return(null);
            }
            ConsumeChar();
            string id = TryReadIdent();

            if (id == null)
            {
                return(null);
            }
            var res = new DepsName();

            res.Components.Add(id);
            JumpWhite();
            while (Current == '.')
            {
                ConsumeChar();
                string id2 = TryReadIdent();
                if (id2 == null)
                {
                    break;
                }
                res.Components.Insert(0, id2);
                JumpWhite();
            }
            return(res);
        }
Beispiel #2
0
 public bool Match(DepsName name)
 {
     if (Alias != null)
     {
         return(name.Components.Count == 1 && String.Compare(name.Components[0], Alias, true) == 0);
     }
     return(name.SimilarTo(FullName));
 }
Beispiel #3
0
 private NameWithSchema FindItem(DepsName name, List <NameWithSchema> available)
 {
     foreach (var av in available)
     {
         if (name.SimilarTo(av))
         {
             return(av);
         }
     }
     return(null);
 }
Beispiel #4
0
 public void AddName(DepsName name)
 {
     Names.Add(name);
 }
Beispiel #5
0
        private void ProcessToken()
        {
            var tok = m_input.LT(1);
            int la1 = m_input.LA(1), la2 = m_input.LA(2);

            if (la1 == m_tokens.SELECT)
            {
                m_queryType = QueryType.SELECT;
            }
            if (la1 == m_tokens.UPDATE)
            {
                m_queryType = QueryType.UPDATE;
            }
            if (la1 == m_tokens.DELETE)
            {
                m_queryType = QueryType.DELETE;
            }
            if (la1 == m_tokens.INSERT)
            {
                m_queryType = QueryType.INSERT;
            }

            if (la1 == m_tokens.T_STRING)
            {
                var oldctx = m_context;
                SetPositionBegin(tok);
                SetContext(CodeContext.String);
                SetPositionEnd(tok);
                SetContext(oldctx);
                m_input.Consume();
                return;
            }

            if (la1 == m_tokens.SELECT ||
                la1 == m_tokens.WHERE ||
                la1 == m_tokens.ON
                )
            {
                SetPositionEnd(tok);
                SetContext(CodeContext.Column);
                m_input.Consume();
                return;
            }

            if ((la1 == m_tokens.LPAREN && m_queryType == QueryType.INSERT) ||
                la1 == m_tokens.SET
                )
            {
                SetPositionEnd(tok);
                SetContext(CodeContext.ColumnWithoutQualifier);
                m_input.Consume();
                return;
            }

            if (la1 == m_tokens.ORDER && la2 == m_tokens.BY ||
                la1 == m_tokens.GROUP && la2 == m_tokens.BY)
            {
                SetPositionEnd(m_input.LT(2));
                m_input.Consume();
                m_input.Consume();
                SetContext(CodeContext.Column);
                return;
            }
            if (la1 == m_tokens.FROM ||
                la1 == m_tokens.JOIN ||
                la1 == m_tokens.UPDATE ||
                la1 == m_tokens.DELETE ||
                la1 == m_tokens.INSERT
                )
            {
                SetPositionEnd(tok);
                SetContext(CodeContext.Table);
                m_input.Consume();
                return;
            }

            if (m_context == CodeContext.Table && m_tokens.IsIdent(la1))
            {
                var name = new DepsName();
                name.Components.Add(m_dialect.UnquoteName(tok.Text));
                m_input.Consume();
                while (m_input.LA(1) == m_tokens.DOT && m_tokens.IsIdent(m_input.LA(2)))
                {
                    name.Components.Add(m_dialect.UnquoteName(m_input.LT(2).Text));
                    m_input.Consume();
                    m_input.Consume();
                }
                var titem = new TableItem {
                    Name = name
                };
                if (m_tokens.IsIdent(m_input.LA(1)))
                {
                    titem.Alias = m_dialect.UnquoteName(m_input.LT(1).Text);
                    m_input.Consume();
                }
                UsedTables.Add(titem);
                return;
            }

            // default token handling
            m_input.Consume();
            SetPositionEnd(tok);
        }
Beispiel #6
0
 public TableItem FindUsedMatch(DepsName name)
 {
     return(UsedTables.FirstOrDefault(tbl => tbl.Match(name)));
 }