Skip to content

Commit

Permalink
Add JavaDoc for the 'Description' class and all of its subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernLoetters committed Jan 31, 2025
1 parent 45cacd0 commit fe49522
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/src/main/java/jjparse/description/Choice.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@
import java.util.Optional;
import java.util.function.Predicate;

import jjparse.Parsing.Parser;
import jjparse.Parsing;

/**
* A {@link Description} for {@link Parser}s that expect a {@link Parsing#choice}.
*
* @author Björn Lötters
*
* @see Description
* @see Parsing#choice
* @see Parser#description
*/
public final class Choice extends Description {

/** The {@link List} of alternative {@link Description}s. */
public final List<Description> alternatives;


/**
* Constructs a new {@link Choice} {@link Description}.
* @param alternatives The list of alternative {@link Description}s.
*/
public Choice(final List<Description> alternatives) {
this.alternatives = alternatives;
}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/jjparse/description/Description.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @see Sequence
* @see Empty
* @see Parser
* @see Parser#description
*
* @author Björn Lötters
*/
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/jjparse/description/Empty.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package jjparse.description;

import jjparse.Parsing.Parser;

import java.util.Optional;

/**
* A {@link Description} for {@link Parser}s with no expectation hints (which is the default).
*
* @author Björn Lötters
*
* @see Description
* @see Parser#description
*/
public final class Empty extends Description {

@Override
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/java/jjparse/description/Literal.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package jjparse.description;

import jjparse.Parsing.Parser;
import jjparse.StringParsing;

import java.util.Optional;

/**
* A {@link Description} for {@link Parser}s that expect a {@link String} literal.
*
* @author Björn Lötters
*
* @see Description
* @see StringParsing#literal
* @see Parser#description
*/
public final class Literal extends Description {

/** The expected {@link String} literal. */
public final String literal;

/**
* Construct a new {@link Literal} {@link Description}.
* @param literal The expected {@link String} literal.
*/
public Literal(final String literal) {
this.literal = literal == null ? "" : literal.trim();
}
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/java/jjparse/description/Negation.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
package jjparse.description;

import jjparse.Parsing.Parser;

import java.util.Optional;

/**
* A {@link Description} for {@link Parser}s that negate another {@link Parser}'s expectation.
*
* @author Björn Lötters
*
* @see Description
* @see Parser#description
* @see Parser#not
*/
public final class Negation extends Description {

/** The {@link Description} which should be negated. */
public final Description description;

/**
* Constructs a new {@link Negation} {@link Description}.
* @param description The {@link Description} which should be negated.
*/
public Negation(final Description description) {
this.description = description;
}
Expand Down
18 changes: 18 additions & 0 deletions core/src/main/java/jjparse/description/RegExp.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
package jjparse.description;

import jjparse.Parsing.Parser;
import jjparse.StringParsing;

import java.util.Optional;
import java.util.regex.Pattern;

/**
* A {@link Description} for {@link Parser}s that expect a {@link Pattern}.
*
* @author Björn Lötters
*
* @see Description
* @see StringParsing#regex
* @see Parser#description
* @see Pattern
*/
public final class RegExp extends Description {

/** The expected {@link Pattern} of this {@link Description}. */
public final Pattern pattern;

/**
* Constructs a new {@link RegExp} {@link Description}.
* @param pattern The expected {@link Pattern} of this {@link Description}.
*/
public RegExp(final Pattern pattern) {
this.pattern = pattern;
}
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/java/jjparse/description/Sequence.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
package jjparse.description;

import jjparse.Parsing.Parser;
import jjparse.Parsing;

import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;

/**
* A {@link Description} for {@link Parser}s that expect a {@link Parsing#sequence}.
*
* @author Björn Lötters
*
* @see Description
* @see Parsing#sequence
* @see Parser#description
*/
public final class Sequence extends Description {

/** The {@link List} of {@link Description}s. */
public final List<Description> elements;

/**
* Constructs a new {@link Sequence} {@link Description}.
* @param elements The individual {@link Description}s of this {@link Sequence} {@link Description}.
*/
public Sequence(final List<Description> elements) {
this.elements = elements;
}
Expand Down

0 comments on commit fe49522

Please sign in to comment.