Ejemplo n.º 1
0
 antlr.IToken CreateToken(antlr.IToken prototype, int newTokenType, string newTokenText)
 {
     return(new BooToken(newTokenType, newTokenText,
                         prototype.getFilename(),
                         prototype.getLine(),
                         prototype.getColumn() + SafeGetLength(prototype.getText())));
 }
Ejemplo n.º 2
0
 public BooToken(antlr.IToken original, int type, string text)
 {
     setType(type);
     setText(text);
     setFilename(original.getFilename());
     setLine(original.getLine());
     setColumn(original.getColumn());
 }
Ejemplo n.º 3
0
        private Tuple <int, int> CalculateEndpoint(antlr.IToken token, int endLine, int endIndex, int delimiterLength)
        {
            var startIndex = positionMap[token.getLine() - 1][token.getColumn() - 1];
            var startLine  = token.getLine() - 1;

            if (startLine > endLine || startLine == endLine && startIndex > endIndex)
            {
                whitespaces.Add(new TextSpan {
                    iStartLine = endLine, iStartIndex = endIndex, iEndLine = startLine, iEndIndex = startIndex
                });
            }

            endLine  = startLine - 1;
            endIndex = 0;

            var runningIndex = startIndex + delimiterLength;

            foreach (var part in token.getText().Split(new[] { "\r\n" }, StringSplitOptions.None))
            {
                endLine++;
                endIndex     = runningIndex + part.Length;
                runningIndex = 0;
            }
            endIndex += delimiterLength;

            //endIndex = positionMap[endLine][endIndex];

            var cluster = new MappedToken(
                startLine * lineSize + startIndex,
                endIndex - startIndex);

            if (tokenMap.Count > 0 &&
                tokenMap[tokenMap.Count() - 1].Index >= cluster.Index)
            {
                throw new ArgumentException("Token Mapping order");
            }

            tokenMap.Add(cluster);
            return(new Tuple <int, int>(endLine, endIndex));
        }
Ejemplo n.º 4
0
        override public void initialize(IToken tok)
        {
            base.initialize(tok);
            Column = tok.getColumn();
            Line   = tok.getLine();

            CustomHiddenStreamToken ctok = tok as CustomHiddenStreamToken;

            if (null != ctok)
            {
                File = ctok.File;
            }
        }
Ejemplo n.º 5
0
 public int getLine()
 {
     return(iToken.getLine());
 }
Ejemplo n.º 6
0
 public override void initialize(IToken t)
 {
     base.initialize(t);
     line = t.getLine();
     col  = t.getColumn();
 }
Ejemplo n.º 7
0
        public static SourceLocation ToEndSourceLocation(antlr.IToken token)
        {
            string text = token.getText() ?? "";

            return(new SourceLocation(token.getLine(), token.getColumn() + text.Length - 1));
        }
Ejemplo n.º 8
0
 public static SourceLocation ToSourceLocation(antlr.IToken token)
 {
     return(new SourceLocation(token.getLine(), token.getColumn()));
 }
Ejemplo n.º 9
0
 public static LexicalInfo ToLexicalInfo(antlr.IToken token)
 {
     return(new LexicalInfo(token.getFilename(), token.getLine(), token.getColumn()));
 }
Ejemplo n.º 10
0
 public static SourceLocation ToEndSourceLocation(antlr.IToken token)
 {
     return(new SourceLocation(token.getLine(), token.getColumn() + token.getText().Length - 1));
 }