Skip to content

Instantly share code, notes, and snippets.

package com.github.parboiled1.grappa.samples;
import com.github.parboiled1.grappa.helpers.ValueBuilder;
import com.google.common.eventbus.Subscribe;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
public final class StudentBuilder
package com.github.parboiled1.grappa.samples;
import org.parboiled.Parboiled;
import org.parboiled.parserunners.BasicParseRunner;
import org.parboiled.parserunners.ParseRunner;
import org.parboiled.support.ParsingResult;
public final class SampleRun
{
public static void main(final String... args)
private int binarySearch(final int index)
{
return doBinarySearch(0, nrLines - 1, index);
}
private int doBinarySearch(final int low, final int high, final int index)
{
// Guaranteed to always succeed at this point
if (low == high)
return low;
package com.github.parboiled1.grappa.samples;
import com.github.parboiled1.grappa.parsers.EventBusParser;
import org.parboiled.Rule;
import org.parboiled.support.Var;
import java.util.HashMap;
import java.util.Map;
public class TestGrammar2
package com.github.parboiled1.grappa.samples;
import org.parboiled.BaseParser;
import org.parboiled.Rule;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("AutoBoxing")
public class TestGrammar
package com.github.fge.grappa;
import org.parboiled.BaseParser;
import org.parboiled.Rule;
import org.parboiled.annotations.Label;
public class JsonParser
extends BaseParser<Void>
{
@Label("e")
/**
* A joining matcher
*
* <p>Such a matcher has two submatchers: a "joined" matcher and a "joining"
* matcher.</p>
*
* <p>This matcher will run cycles through both of these; the first will be a
* run of the "joined" matcher, subsequent cycles will be ("joining", "joined").
* </p>
*
/**
* The final step to building a {@link JoinMatcher}
*
* <p>At this step of the build, we have both rules (the "joined" rule and the
* "joining" rule). The final information to feed to the matcher is the number
* of cycles.</p>
*
* <p>The number of cycles can be bounded on the lower end and on the upper end.
* The "true" building method is {@link #range(Range)}; all other methods
* ultimately call this one to generate the result.</p>
public static void main(final String... args)
throws IOException
{
final ObjectMapper mapper = new ObjectMapper();
final TypeReference<List<Integer>> typeRef
= new TypeReference<List<Integer>>() {};
final List<Integer> list;
final InputStream in
= EndOfInputMatcher.class.getResourceAsStream("/foo/bar/baz.json");
package com.github.fge.grappa;
import org.parboiled.BaseParser;
import org.parboiled.Rule;
import org.parboiled.annotations.Label;
public class JsonParser
extends BaseParser<Void>
{
@Label("e")