eclipse plugin: add method in grammar tests for showing tokenisation

This commit is contained in:
Timotei Dolean 2010-08-16 09:09:29 +00:00
parent 21469d1dda
commit 6380ed7373
2 changed files with 9 additions and 6 deletions

View File

@ -77,6 +77,13 @@ public abstract class WMLTests extends AbstractXtextTests
}
}
protected void showTokenisation(String input) {
List<Token> tokens = getTokens(input);
for (int i = 0; i < tokens.size(); i++) {
Token token = tokens.get(i);
System.out.println(getTokenType(token));
}
}
/**
* check that an input is not tokenised using a particular terminal rule
* */

View File

@ -24,10 +24,6 @@ public class WMLTestsImpl extends WMLTests
checkTokenisation("abc", ID);
checkTokenisation("abc123", ID);
checkTokenisation("abc_123", ID);
//fail as entity is a keyword
failTokenisation("entity", ID);
failTokenisation("A", ID);
}
public void testSLCOMMENT(){
checkTokenisation("#comment", SL_COMMENT);
@ -37,10 +33,10 @@ public class WMLTestsImpl extends WMLTests
public void testTokenSequences(){
checkTokenisation("123 abc", ID, WS, ID);
checkTokenisation("123 \t#comment\n abc", INT, WS, SL_COMMENT,WS,ID);
checkTokenisation("123 \t#comment\n abc", ID, WS, SL_COMMENT,WS,ID);
//note that no white space is necessary!
checkTokenisation("123abc", INT, ID);
checkTokenisation("123abc", ID);
}
}