@Override public <A, E extends Exception> A matchExpression( final SExpressionMatcherType<A, E> m) throws E { return m.quotedString(this); } }
@Override public <A, E extends Exception> A matchExpression( final SExpressionMatcherType<A, E> m) throws E { return m.list(this); }
@Override public <A, E extends Exception> A matchExpression( final SExpressionMatcherType<A, E> m) throws E { return m.symbol(this); } }
@Override public SizeExprType<Unresolved, Untyped> list( final SExpressionListType le) throws JPRACompilerParseException { if (le.size() == 0) { throw JPRACompilerParseException.expectedNonEmptyList(le); } final SExpressionSymbolType se = JPRAParser.requireSymbol(le.get(0)); JPRAParser.checkSizeFunction(se); switch (se.getText()) { case JPRAParser.SIZE_IN_BITS: { return JPRAParser.this.parseSizeInBits(le, se); } case JPRAParser.SIZE_IN_OCTETS: { return JPRAParser.this.parseSizeInOctets(le, se); } } throw new UnreachableCodeException(); }
@Override public void print(final SExpressionType e) throws IOException { e.matchExpression(this.matcher); }
@Override public Integer symbol( final SExpressionSymbolType ss) throws IOException { w.print(ss.text()); return Integer.valueOf(0); } });
@Override public Integer quotedString( final SExpressionQuotedStringType qs) throws IOException { w.print('"'); w.print(qs.getText()); w.print('"'); return Integer.valueOf(0); }
@Override public Integer quotedString( final SExpressionQuotedStringType qs) throws IOException { w.print('"'); w.print(qs.text()); w.print('"'); return Integer.valueOf(0); }
@Override public Unit symbol(final SExpressionSymbolType e) throws IOException { JSXPrettyPrinterCodeStyle.this.layout.print(e.getText()); return Unit.unit(); } };
/** * The type of lexer configurations. */ @JSXImmutableStyleType @Value.Immutable public interface JSXParserConfigurationType { /** * @return {@code true} iff lexical information should be preserved by the * parser */ @Value.Parameter(order = 0) @Value.Default default boolean preserveLexical() { return true; } }
private static Optional<ImmutableLexicalPositionType<Path>> getExpressionLexical(final SExpressionType q) { final Optional<LexicalPositionType<Path>> lex = q.getLexicalInformation(); return lex.map(ImmutableLexicalPosition::newFrom); }
private static Optional<LexicalPosition<Path>> getExpressionLexical(final SExpressionType q) { return q.lexical().map(LexicalPosition::copyOf); }
@Override public void print(final SExpressionType e) throws IOException { e.matchExpression(this.matcher); }
@Override public <A, E extends Exception> A matchExpression( final SExpressionMatcherType<A, E> m) throws E { return m.quotedString(this); } }
@Override public <A, E extends Exception> A matchExpression( final SExpressionMatcherType<A, E> m) throws E { return m.list(this); }
@Override public <A, E extends Exception> A matchExpression( final SExpressionMatcherType<A, E> m) throws E { return m.symbol(this); } }
/** * An error produced during validation of an S-expression. */ @Value.Immutable @JSXImmutableStyleType public interface JSXValidationErrorType { /** * @return The lexical information */ @Value.Parameter LexicalPositionType<URI> lex(); /** * @return The error message */ @Value.Parameter String message(); }
private static SExpressionListType requireList(final SExpressionType e) throws JPRACompilerParseException { return e.matchExpression( new SExpressionMatcherType<SExpressionListType, JPRACompilerParseException>() { @Override public SExpressionListType list(final SExpressionListType le) throws JPRACompilerParseException { return le; } @Override public SExpressionListType quotedString( final SExpressionQuotedStringType qe) throws JPRACompilerParseException { throw JPRACompilerParseException.expectedListGotQuotedString(qe); } @Override public SExpressionListType symbol(final SExpressionSymbolType se) throws JPRACompilerParseException { throw JPRACompilerParseException.expectedListGotSymbol(se); } }); }
private static SExpressionListType requireList(final SExpressionType e) throws JPRACompilerParseException { return e.matchExpression( new SExpressionMatcherType<SExpressionListType, JPRACompilerParseException>() { @Override public SExpressionListType list(final SExpressionListType le) throws JPRACompilerParseException { return le; } @Override public SExpressionListType quotedString( final SExpressionQuotedStringType qe) throws JPRACompilerParseException { throw JPRACompilerParseException.expectedListGotQuotedString(qe); } @Override public SExpressionListType symbol(final SExpressionSymbolType se) throws JPRACompilerParseException { throw JPRACompilerParseException.expectedListGotSymbol(se); } }); }
private static SExpressionSymbolType requireSymbol( final SExpressionType e) throws JPRACompilerParseException { return e.matchExpression( new SExpressionMatcherType<SExpressionSymbolType, JPRACompilerParseException>() { @Override public SExpressionSymbolType list(final SExpressionListType le) throws JPRACompilerParseException { throw JPRACompilerParseException.expectedSymbolGotList(le); } @Override public SExpressionSymbolType quotedString( final SExpressionQuotedStringType qe) throws JPRACompilerParseException { throw JPRACompilerParseException.expectedSymbolGotQuotedString(qe); } @Override public SExpressionSymbolType symbol(final SExpressionSymbolType se) throws JPRACompilerParseException { return se; } }); }