예제 #1
0
        private void lexKeyWord()
        {
            int offset = reader.offset() - 1;

            StringBuilder buf = new StringBuilder();

            while (true)
            {
                int c = reader.read();
                if (c < 0)
                {
                    break;
                }
                if (!Util.isIdentifierPart((char)c))
                {
                    reader.unread();
                    break;
                }
                buf.Append((char)c);
            }
            String s = buf.ToString();

            foreach (var rule in keyWordRules)
            {
                if (rule.Detected(s, reader))
                {
                    tok = rule.token;
                    int len = rule.getLen(s, reader);
                    reader.setoffset(offset + len);
                    OffsetLenAttr = new Tuple <int, int, Rule>(offset, len, rule);
                    break;
                }
            }
        }
예제 #2
0
 public override int getLen(string sequence, LexerReader reader)
 {
     if (sequence == this.start)
     {
         return(base.getLen(sequence, reader));
     }
     else
     {
         return(reader.offset());
     }
 }
예제 #3
0
        public override int getLen(string sequence, LexerReader reader)
        {
            int off   = reader.offset();
            int index = reader.Src.ToString().IndexOfAny(c, off);

            if (index < 0)
            {
                return(reader.Src.Length - off);
            }
            else
            {
                return(index - off);
            }
        }
예제 #4
0
        public override int getLen(string sequence, LexerReader reader)
        {
            int off   = reader.offset();
            int index = reader.Src.IndexOf(this.end, off);

            if (index < 0)
            {
                return(reader.Src.Length - (off - this.start.Length));
            }
            else
            {
                return(index - (off - this.start.Length) + this.end.Length);
            }
        }
예제 #5
0
파일: Rule.cs 프로젝트: mohammadul/addondev
 public override int getLen(string sequence, LexerReader reader)
 {
     if (sequence == this.start) {
         return base.getLen(sequence, reader);
     } else {
         return reader.offset();
     }
 }
예제 #6
0
파일: Rule.cs 프로젝트: mohammadul/addondev
 public override int getLen(string sequence, LexerReader reader)
 {
     int off = reader.offset();
     int index = reader.Src.ToString().IndexOfAny(c, off);
     if (index < 0) {
         return reader.Src.Length - off;
     } else {
         return index - off;
     }
 }
예제 #7
0
파일: Rule.cs 프로젝트: mohammadul/addondev
 public override int getLen(string sequence, LexerReader reader)
 {
     return reader.Src.Length - reader.offset() + this.start.Length;
 }
예제 #8
0
파일: Rule.cs 프로젝트: mohammadul/addondev
 public override int getLen(string sequence, LexerReader reader)
 {
     int off = reader.offset();
     int index = reader.Src.IndexOf(this.end, off);
     if (index < 0) {
         return reader.Src.Length - (off-this.start.Length);
     } else {
         return index - (off - this.start.Length) + this.end.Length;
     }
 }
예제 #9
0
 public override int getLen(string sequence, LexerReader reader)
 {
     return(reader.Src.Length - reader.offset() + this.start.Length);
 }