com.sun.tools.javac.parser.Tokens.Token Java Examples
The following examples show how to use
com.sun.tools.javac.parser.Tokens.Token.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompletenessAnalyzer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private CT match(TK tk, TokenKind open) { Token tok = advance(); db("match desired-tk=%s, open=%s, seen-tok=%s", tk, open, tok.kind); if (stack.isEmpty()) { return new CT(ERROR, tok, "Encountered '" + tok + "' with no opening '" + open + "'"); } Token p = stack.pop(); if (p.kind != open) { return new CT(ERROR, tok, "No match for '" + p + "' instead encountered '" + tok + "'"); } return new CT(tk, tok); }
Example #2
Source File: Documentifier.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Comment comment(String docString) { StringBuilder docComment = new StringBuilder() .append("/**") .append(docString) .append("*/"); Scanner scanner = scanners.newScanner(docComment, true); scanner.nextToken(); Token token = scanner.token(); return token.comment(CommentStyle.JAVADOC); }
Example #3
Source File: JavaLexerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void assertKind(String input, JavaTokenizer tokenizer, TokenKind kind, String expectedText) { Token token = tokenizer.readToken(); if (token.kind != kind) { throw new AssertionError("Unexpected token kind: " + token.kind); } String actualText = input.substring(token.pos, token.endPos); if (!Objects.equals(actualText, expectedText)) { throw new AssertionError("Unexpected token text: " + actualText); } }
Example #4
Source File: TestJavacTaskScanner.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #5
Source File: TestJavacTaskScanner.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #6
Source File: TestJavacTaskScanner.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #7
Source File: TestJavacTaskScanner.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #8
Source File: CompletenessAnalyzer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private CT(TK tk, Token tok, String msg) { this.kind = tk; this.endPos = tok.endPos; this.message = msg; //throw new InternalError(msg); /* for debugging */ }
Example #9
Source File: CompletenessAnalyzer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private CT(TK tk, Token tok) { this.kind = tk; this.endPos = tok.endPos; this.message = null; }
Example #10
Source File: CompletenessAnalyzer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private Token advance() { Token prev = current; scanner.nextToken(); current = scanner.token(); return prev; }
Example #11
Source File: TestJavacTaskScanner.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #12
Source File: TestJavacTaskScanner.java From hottub with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #13
Source File: TestJavacTaskScanner.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #14
Source File: TestJavacTaskScanner.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public void nextToken() { super.nextToken(); Token tk = token(); System.err.format("Saw token %s %n", tk.kind); test.numTokens++; }
Example #15
Source File: CommentCollectingTokenizer.java From EasyMPermission with MIT License | 4 votes |
@Override public Token readToken() { Token token = super.readToken(); prevEndPosition = ((PositionUnicodeReader)reader).pos(); return token; }
Example #16
Source File: JavacTokens.java From google-java-format with Apache License 2.0 | 4 votes |
/** Lex the input and return a list of {@link RawTok}s. */ public static ImmutableList<RawTok> getTokens( String source, Context context, Set<TokenKind> stopTokens) { if (source == null) { return ImmutableList.of(); } ScannerFactory fac = ScannerFactory.instance(context); char[] buffer = (source + EOF_COMMENT).toCharArray(); Scanner scanner = new AccessibleScanner(fac, new CommentSavingTokenizer(fac, buffer, buffer.length)); ImmutableList.Builder<RawTok> tokens = ImmutableList.builder(); int end = source.length(); int last = 0; do { scanner.nextToken(); Token t = scanner.token(); if (t.comments != null) { for (Comment c : Lists.reverse(t.comments)) { if (last < c.getSourcePos(0)) { tokens.add(new RawTok(null, null, last, c.getSourcePos(0))); } tokens.add( new RawTok(null, null, c.getSourcePos(0), c.getSourcePos(0) + c.getText().length())); last = c.getSourcePos(0) + c.getText().length(); } } if (stopTokens.contains(t.kind)) { if (t.kind != TokenKind.EOF) { end = t.pos; } break; } if (last < t.pos) { tokens.add(new RawTok(null, null, last, t.pos)); } tokens.add( new RawTok( t.kind == TokenKind.STRINGLITERAL ? "\"" + t.stringVal() + "\"" : null, t.kind, t.pos, t.endPos)); last = t.endPos; } while (scanner.token().kind != TokenKind.EOF); if (last < end) { tokens.add(new RawTok(null, null, last, end)); } return tokens.build(); }