com.sun.tools.javac.parser.Tokens.TokenKind Java Examples
The following examples show how to use
com.sun.tools.javac.parser.Tokens.TokenKind.
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: JavaInput.java From google-java-format with Apache License 2.0 | 6 votes |
/** * The {@code Tok} constructor. * * @param index its index * @param originalText its original text, before removing Unicode escapes * @param text its text after removing Unicode escapes * @param position its {@code 0}-origin position in the input * @param columnI its {@code 0}-origin column number in the input * @param isToken whether the {@code Tok} is a token * @param kind the token kind */ Tok( int index, String originalText, String text, int position, int columnI, boolean isToken, TokenKind kind) { this.index = index; this.originalText = originalText; this.text = text; this.position = position; this.columnI = columnI; this.isToken = isToken; this.kind = kind; }
Example #2
Source File: DocCommentParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #3
Source File: ReferenceParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #4
Source File: JavaLexerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context ctx = new Context(); Log log = Log.instance(ctx); String input = "0bL 0b20L 0xL "; log.useSource(new SimpleJavaFileObject(new URI("mem://Test.java"), JavaFileObject.Kind.SOURCE) { @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return input; } }); char[] inputArr = input.toCharArray(); JavaTokenizer tokenizer = new JavaTokenizer(ScannerFactory.instance(ctx), inputArr, inputArr.length) { }; assertKind(input, tokenizer, TokenKind.LONGLITERAL, "0bL"); assertKind(input, tokenizer, TokenKind.LONGLITERAL, "0b20L"); assertKind(input, tokenizer, TokenKind.LONGLITERAL, "0xL"); }
Example #5
Source File: DocCommentParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #6
Source File: DocCommentParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #7
Source File: DocCommentParser.java From hottub with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #8
Source File: ReferenceParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #9
Source File: DocCommentParser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #10
Source File: DocCommentParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #11
Source File: DocCommentParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #12
Source File: DocCommentParser.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #13
Source File: DocCommentParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example #14
Source File: DocCommentParser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #15
Source File: DocCommentParser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
JCTree parseType(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); JCTree tree = p.parseType(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return tree; }
Example #16
Source File: DocCommentParser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
JCTree parseType(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); JCTree tree = p.parseType(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return tree; }
Example #17
Source File: DocCommentParser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #18
Source File: DocCommentParser.java From hottub with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #19
Source File: DocCommentParser.java From hottub with GNU General Public License v2.0 | 5 votes |
JCTree parseType(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); JCTree tree = p.parseType(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return tree; }
Example #20
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 #21
Source File: ModifierOrderer.java From google-java-format with Apache License 2.0 | 5 votes |
/** * Returns the {@link javax.lang.model.element.Modifier} for the given token kind, or {@code * null}. */ private static Modifier getModifier(TokenKind kind) { if (kind == null) { return null; } switch (kind) { case PUBLIC: return Modifier.PUBLIC; case PROTECTED: return Modifier.PROTECTED; case PRIVATE: return Modifier.PRIVATE; case ABSTRACT: return Modifier.ABSTRACT; case STATIC: return Modifier.STATIC; case DEFAULT: return Modifier.DEFAULT; case FINAL: return Modifier.FINAL; case TRANSIENT: return Modifier.TRANSIENT; case VOLATILE: return Modifier.VOLATILE; case SYNCHRONIZED: return Modifier.SYNCHRONIZED; case NATIVE: return Modifier.NATIVE; case STRICTFP: return Modifier.STRICTFP; default: return null; } }
Example #22
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 #23
Source File: CompletenessAnalyzer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static TK tokenKindToTK(TK prev, TokenKind kind) { TK tk = tokenKindToTKMap.get(kind); if (tk == null) { System.err.printf("No corresponding %s for %s: %s\n", TK.class.getCanonicalName(), TokenKind.class.getCanonicalName(), kind); throw new InternalError("No corresponding TK for TokenKind: " + kind); } return tk.mapping != null ? tk.mapping.apply(prev) : tk; }
Example #24
Source File: DocCommentParser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #25
Source File: DocCommentParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #26
Source File: DocCommentParser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
JCTree parseType(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); JCTree tree = p.parseType(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return tree; }
Example #27
Source File: DocCommentParser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #28
Source File: DocCommentParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
JCTree parseType(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); JCTree tree = p.parseType(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return tree; }
Example #29
Source File: DocCommentParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
Name parseMember(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); Name name = p.ident(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return name; }
Example #30
Source File: ReferenceParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JCTree parseType(String s) throws ParseException { JavacParser p = fac.newParser(s, false, false, false); JCTree tree = p.parseType(); if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return tree; }