Package org.renjin.studio.syntax

Source Code of org.renjin.studio.syntax.TokenMakerTest

package org.renjin.studio.syntax;

import javax.swing.text.Segment;

import org.fife.ui.rsyntaxtextarea.RenjinTokenMaker;
import org.fife.ui.rsyntaxtextarea.Token;
import org.fife.ui.rsyntaxtextarea.modes.JavaScriptTokenMaker;
import org.junit.Ignore;
import org.junit.Test;

@Ignore
public class TokenMakerTest {

 
  @Test
  public void testUnderstanding() {
   
    String code = "f = function(x) {\n return(1+x);\n}";
    JavaScriptTokenMaker tokenMaker = new JavaScriptTokenMaker();
    Token tokenList = tokenMaker.getTokenList(new Segment(code.toCharArray(), 0, code.length()), 0, 0);
   
    tokenList = dumpTokenList(tokenList);
  }
 
  @Test
  public void testRenjin() {
   
    String code = "f <- function(x) {\n return(1+x);\n}";
    RenjinTokenMaker tokenMaker = new RenjinTokenMaker();
    Token tokenList = tokenMaker.getTokenList(new Segment(code.toCharArray(), 0, code.length()), 0, 0);
   
    tokenList = dumpTokenList(tokenList);
  }

  private Token dumpTokenList(Token tokenList) {
    while(tokenList != null) {
      System.out.println("=====Token====");
      System.out.println(tokenList.getLexeme());
      System.out.println("type = " + tokenList.type);
//      System.out.println(new String(tokenList.text));
//      System.out.println("--------------");
//      System.out.println("offset:     " + tokenList.offset);
//      System.out.println("textCount:  " + tokenList.textCount);
//      System.out.println("textOffset: " + tokenList.textOffset);
//      System.out.println("type:       " + tokenList.type);
      tokenList = tokenList.getNextToken();
    }
    return tokenList;
  }
}
TOP

Related Classes of org.renjin.studio.syntax.TokenMakerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.