diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-21 19:29:27 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-21 19:38:42 -0400 |
| commit | 5444cd4db8a0fa41d25cd303c1145cadd112e12f (patch) | |
| tree | 779f205becc1e1cded6ed1c307f295a2404ce22d /RGens/src/main/java/bjc/rgens/newparser/CaseElement.java | |
| parent | ccb2510fadf19e5e1cda63d948fd482e25fc799d (diff) | |
Add formatter
Adds a formatter capable of taking in a parsed grammar and printing it out
in a formatted form, capable of being reparsed.
Diffstat (limited to 'RGens/src/main/java/bjc/rgens/newparser/CaseElement.java')
| -rw-r--r-- | RGens/src/main/java/bjc/rgens/newparser/CaseElement.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/RGens/src/main/java/bjc/rgens/newparser/CaseElement.java b/RGens/src/main/java/bjc/rgens/newparser/CaseElement.java index fe088b8..a15cb9b 100644 --- a/RGens/src/main/java/bjc/rgens/newparser/CaseElement.java +++ b/RGens/src/main/java/bjc/rgens/newparser/CaseElement.java @@ -92,11 +92,35 @@ public class CaseElement { } /** + + /** * Get the literal string value for this element. * * @return The literal string value for this element. + * + * @throws IllegalStateException + * If this type doesn't have a literal string value. */ public String getLiteral() { + switch(type) { + case LITERAL: + case RULEREF: + break; + default: + throw new IllegalStateException(String.format("Type '%s' doesn't have a literal string value")); + } + return literalVal; } + + @Override + public String toString() { + switch(type) { + case LITERAL: + case RULEREF: + return literalVal; + default: + return String.format("Unknown type '%s'", type); + } + } }
\ No newline at end of file |
