diff --git a/src/main/java/controlP5/Textfield.java b/src/main/java/controlP5/Textfield.java index c538633..8979dfc 100755 --- a/src/main/java/controlP5/Textfield.java +++ b/src/main/java/controlP5/Textfield.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import controlP5.events.ReleasedOutsideListener; +import controlP5.textfield.TextfieldCommand; import processing.core.PApplet; import processing.core.PFont; import processing.core.PGraphics; @@ -394,9 +395,7 @@ public class Textfield extends Controller< Textfield > implements ReleasedOutsid return this; } - interface TextfieldCommand { - void execute( ); - } + class InsertCharacter implements TextfieldCommand { diff --git a/src/main/java/controlP5/TextfieldCommand.java b/src/main/java/controlP5/TextfieldCommand.java new file mode 100644 index 0000000..4cbdb3a --- /dev/null +++ b/src/main/java/controlP5/TextfieldCommand.java @@ -0,0 +1,5 @@ +package controlP5.textfield; + +public interface TextfieldCommand { + void execute( ); +} \ No newline at end of file diff --git a/src/main/java/controlP5/TextfieldMultiline.java b/src/main/java/controlP5/TextfieldMultiline.java deleted file mode 100755 index 34a0d3b..0000000 --- a/src/main/java/controlP5/TextfieldMultiline.java +++ /dev/null @@ -1,223 +0,0 @@ -package controlP5; - -import processing.core.PApplet; -import processing.core.PGraphics; - -import java.util.ArrayList; - -import controlP5.ControlEvent; -import controlP5.ControlFont; -import controlP5.ControlListener; -import controlP5.ControlP5; -import controlP5.Slider; -import controlP5.Textfield; - -/** - * a textarea can be used to leave notes, it uses the controlP5 BitFont to - * render text. Scrollbars - * will automatically be added when text extends the visible area. Textarea - * extends ControllerGroup, - * for more methods available see the ControllerGroup documentation. - * - * @example controllers/ControlP5textarea - */ - -public class TextfieldMultiline extends Textfield implements ControlListener { - - public boolean isScrollbarVisible = false; - protected Slider _myScrollbar; - - public int _myWidth = 300; - protected int _myTextBufferRowIndex = 0; - protected int _myTextBufferColumnIndex = 0; - - private ArrayList _myTextBuffer = new ArrayList(); - - public TextfieldMultiline(ControlP5 theControlP5, String theName) { - super(theControlP5, theName); - _myValueLabel.setLabeltype(_myValueLabel.new MultilineLabel()); - _myTextBuffer = new ArrayList<>(_myTextBuffer); - keyMapping.put(ENTER, new NewLine()); - keyMapping.put(DOWN, new MoveDown()); - keyMapping.put(UP, new MoveUp()); - keyMapping.put(LEFT, new MoveLeft()); - keyMapping.put(RIGHT, new MoveRight()); - keyMapping.put(DEFAULT, new InsertCharacter()); - keyMapping.put(BACKSPACE, new DeleteCharacter()); - } - - class InsertCharacter implements TextfieldCommand { - - public void execute() { - - if ((int) (cp5.getKey()) == 65535) { - return; - } - - if (_myInputFilter.apply(cp5.getKey())) { - - _myTextBuffer.get(_myTextBufferRowIndex).insert(_myTextBufferColumnIndex, (char) cp5.getKey()); - _myTextBufferColumnIndex += 1; - - } - } - } - - class DeleteCharacter implements TextfieldCommand { - public void execute() { - if (_myTextBufferColumnIndex > 0) { - _myTextBuffer.get(_myTextBufferRowIndex).deleteCharAt(_myTextBufferColumnIndex - 1); - _myTextBufferColumnIndex -= 1; - } - } - } - - class NewLine implements TextfieldCommand { - public void execute() { - _myTextBuffer.add(_myTextBufferRowIndex + 1, new StringBuffer()); - _myTextBufferRowIndex += 1; - _myTextBufferColumnIndex = 0; - } - } - - class MoveDown implements TextfieldCommand { - public void execute() { - // if not at the last line - if (_myTextBufferRowIndex < _myTextBuffer.size() - 1) { - // if the next line is shorter than the current line - // set cursor to the end of the next line - if (_myTextBuffer.get(_myTextBufferRowIndex + 1).length() < _myTextBufferColumnIndex) { - _myTextBufferColumnIndex = _myTextBuffer.get(_myTextBufferRowIndex + 1).length(); - } - _myTextBufferRowIndex += 1; - } - } - } - - class MoveUp implements TextfieldCommand { - public void execute() { - if (_myTextBufferRowIndex > 0) { - // if the next line is shorter than the current line - // set cursor to the end of the next line - if (_myTextBuffer.get(_myTextBufferRowIndex - 1).length() < _myTextBufferColumnIndex) { - _myTextBufferColumnIndex = _myTextBuffer.get(_myTextBufferRowIndex - 1).length(); - } - _myTextBufferRowIndex -= 1; - } - - } - } - - class MoveLeft implements TextfieldCommand { - public void execute() { - // if not at the first char - if(_myTextBufferColumnIndex > 0) { - _myTextBufferColumnIndex -= 1; - }// if at the first char of a line - else if(_myTextBufferColumnIndex == 0 && _myTextBufferRowIndex > 0) { - _myTextBufferRowIndex -= 1; - _myTextBufferColumnIndex = _myTextBuffer.get(_myTextBufferRowIndex).length(); - } - } - } - - class MoveRight implements TextfieldCommand { - public void execute() { - if(_myTextBufferColumnIndex < _myTextBuffer.get(_myTextBufferRowIndex).length()) { - _myTextBufferColumnIndex += 1; - }else if (_myTextBufferColumnIndex == _myTextBuffer.get(_myTextBufferRowIndex).length() && _myTextBufferRowIndex < _myTextBuffer.size() - 1) { - _myTextBufferRowIndex += 1; - _myTextBufferColumnIndex = 0; - } - } - } - - @Override - public void controlEvent(ControlEvent theEvent) { - - } - - @Override - public void draw(PGraphics theGraphics) { - - theGraphics.pushStyle(); - theGraphics.fill(color.getBackground()); - theGraphics.pushMatrix(); - theGraphics.translate(x(position), y(position)); - theGraphics.rect(0, 0, getWidth(), getHeight()); - theGraphics.noStroke(); - - theGraphics.fill(_myColorCursor); - theGraphics.pushMatrix(); - theGraphics.pushStyle(); - - buffer.beginDraw(); - buffer.background(0, 0); - final String text = getText(); - final int textWidth = ControlFont.getWidthFor(text.substring(0, _myTextBufferColumnIndex), _myValueLabel,buffer); - final int dif = PApplet.max(textWidth - _myValueLabel.getWidth(), 0); - final String thisLine = _myTextBuffer.get(_myTextBufferRowIndex).toString(); - final int _myTextBufferIndexPosition = ControlFont.getWidthFor(thisLine.substring(0, _myTextBufferColumnIndex), - _myValueLabel, buffer); - _myValueLabel.setText(text); - _myValueLabel.draw(buffer, -dif, 0, this); - buffer.noStroke(); - if (isTexfieldActive) { - if (!cp5.papplet.keyPressed) { - buffer.fill(_myColorCursor, PApplet.abs(PApplet.sin(cp5.papplet.frameCount * 0.05f)) * 255); - } else { - buffer.fill(_myColorCursor); - } - - buffer.rect(PApplet.max(1, PApplet.min(_myTextBufferIndexPosition, _myValueLabel.getWidth() - 3)), - (_myTextBufferRowIndex) * _myValueLabel.getLineHeight(), 1, 10); - } - buffer.endDraw(); - theGraphics.image(buffer, 0, 0); - - theGraphics.popStyle(); - theGraphics.popMatrix(); - - theGraphics.fill(isTexfieldActive ? color.getActive() : color.getForeground()); - theGraphics.rect(0, 0, getWidth(), 1); - theGraphics.rect(0, getHeight() - 1, getWidth(), 1); - theGraphics.rect(-1, 0, 1, getHeight()); - theGraphics.rect(getWidth(), 0, 1, getHeight()); - _myCaptionLabel.draw(theGraphics, 0, 0, this); - theGraphics.popMatrix(); - theGraphics.popStyle(); - } - - @Override - public String getText() { - StringBuilder sb = new StringBuilder(); - for (StringBuffer s : _myTextBuffer) { - sb.append(s.toString() + "\n"); - } - return sb.toString(); - } - - @Override - public Textfield setValue(String theText) { - _myTextBuffer = new ArrayList(); - - // split theText into lines - String[] lines = theText.split("\n"); - for (int i = 0; i < lines.length; i++) { - _myTextBuffer.add(i, new StringBuffer(lines[i])); - } - - return this; - } - - public Textfield setText(String theText) { - return setValue(theText); - } - - public Textfield setIndex(int theColIndex, int theRowIndex) { - _myTextBufferColumnIndex = theColIndex; - _myTextBufferRowIndex = theRowIndex; - return this; - } - -} \ No newline at end of file diff --git a/src/main/java/controlP5/layout/LayoutBuilder.java b/src/main/java/controlP5/layout/LayoutBuilder.java new file mode 100644 index 0000000..f450a2e --- /dev/null +++ b/src/main/java/controlP5/layout/LayoutBuilder.java @@ -0,0 +1,43 @@ +package controlP5.layout; + +import controlP5.layout.lang.XMLBaseListener; +import controlP5.layout.lang.XMLLexer; +import controlP5.layout.lang.XMLParser; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.tree.*; + +public class LayoutBuilder { + + public static void parseXML(String xml) throws Exception { + ANTLRInputStream input = new ANTLRInputStream(xml); + XMLLexer lexer = new XMLLexer(input); + CommonTokenStream tokens = new CommonTokenStream(lexer); + XMLParser parser = new XMLParser(tokens); + ParseTree tree = parser.document(); + + ParseTreeWalker walker = new ParseTreeWalker(); + XMLListener listener = new XMLListener(); + walker.walk(listener, tree); + } + + private static class XMLListener extends XMLBaseListener { + @Override + public void enterStartTag(XMLParser.StartTagContext ctx) { + String controlName = ctx.Name().getText(); + + // Create ControlP5 instance based on controlName + // ControlP5 control = ControlP5Factory.create(controlName); + + int attrCount = ctx.attribute().size(); + for(int i = 0; i < attrCount; i++) { + String attrName = ctx.attribute(i).Name().getText(); + String attrValue = ctx.attribute(i).STRING().getText(); + + // Set attribute + // control.setAttribute(attrName, attrValue); + } + + // After setting all attributes, you could add the control to your UI or store it somewhere + } + } +} diff --git a/src/main/java/controlP5/layout/XML.g4 b/src/main/java/controlP5/layout/XML.g4 new file mode 100644 index 0000000..b26517e --- /dev/null +++ b/src/main/java/controlP5/layout/XML.g4 @@ -0,0 +1,31 @@ +grammar XML; + +document : element EOF ; + +element : startTag (content | SPACE)* endTag + | SELF_CLOSING + ; + +startTag : OPEN Name attribute* CLOSE ; + +endTag : OPEN_SLASH Name CLOSE ; + +SELF_CLOSING : OPEN Name SLASH_CLOSE ; + +attribute : Name EQUALS STRING ; + +content : element | STRING ; + + +SPACE : [ \t\r\n] ; +OPEN : '<' ; +OPEN_SLASH: '' ; +SLASH_CLOSE: '/>' ; +EQUALS : '=' ; + +Name : ALPHA (ALPHA | DIGIT | '.' | '-' | '_')* ; +STRING : '"' ( ~'"' )* '"' | '\'' ( ~'\'' )* '\'' ; + +fragment DIGIT : [0-9] ; +fragment ALPHA : [a-zA-Z] ; diff --git a/src/main/java/controlP5/layout/lang/XML.interp b/src/main/java/controlP5/layout/lang/XML.interp new file mode 100644 index 0000000..e4fb8d8 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XML.interp @@ -0,0 +1,35 @@ +token literal names: +null +null +null +'<' +'' +'/>' +'=' +null +null + +token symbolic names: +null +SELF_CLOSING +SPACE +OPEN +OPEN_SLASH +CLOSE +SLASH_CLOSE +EQUALS +Name +STRING + +rule names: +document +element +startTag +endTag +attribute +content + + +atn: +[4, 1, 9, 51, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 5, 1, 19, 8, 1, 10, 1, 12, 1, 22, 9, 1, 1, 1, 1, 1, 1, 1, 3, 1, 27, 8, 1, 1, 2, 1, 2, 1, 2, 5, 2, 32, 8, 2, 10, 2, 12, 2, 35, 9, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 3, 5, 49, 8, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 0, 49, 0, 12, 1, 0, 0, 0, 2, 26, 1, 0, 0, 0, 4, 28, 1, 0, 0, 0, 6, 38, 1, 0, 0, 0, 8, 42, 1, 0, 0, 0, 10, 48, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, 13, 14, 5, 0, 0, 1, 14, 1, 1, 0, 0, 0, 15, 20, 3, 4, 2, 0, 16, 19, 3, 10, 5, 0, 17, 19, 5, 2, 0, 0, 18, 16, 1, 0, 0, 0, 18, 17, 1, 0, 0, 0, 19, 22, 1, 0, 0, 0, 20, 18, 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 23, 1, 0, 0, 0, 22, 20, 1, 0, 0, 0, 23, 24, 3, 6, 3, 0, 24, 27, 1, 0, 0, 0, 25, 27, 5, 1, 0, 0, 26, 15, 1, 0, 0, 0, 26, 25, 1, 0, 0, 0, 27, 3, 1, 0, 0, 0, 28, 29, 5, 3, 0, 0, 29, 33, 5, 8, 0, 0, 30, 32, 3, 8, 4, 0, 31, 30, 1, 0, 0, 0, 32, 35, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 36, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 36, 37, 5, 5, 0, 0, 37, 5, 1, 0, 0, 0, 38, 39, 5, 4, 0, 0, 39, 40, 5, 8, 0, 0, 40, 41, 5, 5, 0, 0, 41, 7, 1, 0, 0, 0, 42, 43, 5, 8, 0, 0, 43, 44, 5, 7, 0, 0, 44, 45, 5, 9, 0, 0, 45, 9, 1, 0, 0, 0, 46, 49, 3, 2, 1, 0, 47, 49, 5, 9, 0, 0, 48, 46, 1, 0, 0, 0, 48, 47, 1, 0, 0, 0, 49, 11, 1, 0, 0, 0, 5, 18, 20, 26, 33, 48] \ No newline at end of file diff --git a/src/main/java/controlP5/layout/lang/XML.tokens b/src/main/java/controlP5/layout/lang/XML.tokens new file mode 100644 index 0000000..f1d8167 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XML.tokens @@ -0,0 +1,14 @@ +SELF_CLOSING=1 +SPACE=2 +OPEN=3 +OPEN_SLASH=4 +CLOSE=5 +SLASH_CLOSE=6 +EQUALS=7 +Name=8 +STRING=9 +'<'=3 +''=5 +'/>'=6 +'='=7 diff --git a/src/main/java/controlP5/layout/lang/XMLBaseListener.java b/src/main/java/controlP5/layout/lang/XMLBaseListener.java new file mode 100644 index 0000000..90a3ea5 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XMLBaseListener.java @@ -0,0 +1,112 @@ +// Generated from XML.g4 by ANTLR 4.13.0 +package controlP5.layout.lang; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link XMLListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class XMLBaseListener implements XMLListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDocument(XMLParser.DocumentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDocument(XMLParser.DocumentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterElement(XMLParser.ElementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitElement(XMLParser.ElementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStartTag(XMLParser.StartTagContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStartTag(XMLParser.StartTagContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEndTag(XMLParser.EndTagContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEndTag(XMLParser.EndTagContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAttribute(XMLParser.AttributeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAttribute(XMLParser.AttributeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterContent(XMLParser.ContentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitContent(XMLParser.ContentContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/main/java/controlP5/layout/lang/XMLLexer.interp b/src/main/java/controlP5/layout/lang/XMLLexer.interp new file mode 100644 index 0000000..ed666d1 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XMLLexer.interp @@ -0,0 +1,46 @@ +token literal names: +null +null +null +'<' +'' +'/>' +'=' +null +null + +token symbolic names: +null +SELF_CLOSING +SPACE +OPEN +OPEN_SLASH +CLOSE +SLASH_CLOSE +EQUALS +Name +STRING + +rule names: +SELF_CLOSING +SPACE +OPEN +OPEN_SLASH +CLOSE +SLASH_CLOSE +EQUALS +Name +STRING +DIGIT +ALPHA + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 9, 72, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 46, 8, 7, 10, 7, 12, 7, 49, 9, 7, 1, 8, 1, 8, 5, 8, 53, 8, 8, 10, 8, 12, 8, 56, 9, 8, 1, 8, 1, 8, 1, 8, 5, 8, 61, 8, 8, 10, 8, 12, 8, 64, 9, 8, 1, 8, 3, 8, 67, 8, 8, 1, 9, 1, 9, 1, 10, 1, 10, 0, 0, 11, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 0, 21, 0, 1, 0, 6, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 45, 46, 95, 95, 1, 0, 34, 34, 1, 0, 39, 39, 1, 0, 48, 57, 2, 0, 65, 90, 97, 122, 75, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 1, 23, 1, 0, 0, 0, 3, 27, 1, 0, 0, 0, 5, 29, 1, 0, 0, 0, 7, 31, 1, 0, 0, 0, 9, 34, 1, 0, 0, 0, 11, 36, 1, 0, 0, 0, 13, 39, 1, 0, 0, 0, 15, 41, 1, 0, 0, 0, 17, 66, 1, 0, 0, 0, 19, 68, 1, 0, 0, 0, 21, 70, 1, 0, 0, 0, 23, 24, 3, 5, 2, 0, 24, 25, 3, 15, 7, 0, 25, 26, 3, 11, 5, 0, 26, 2, 1, 0, 0, 0, 27, 28, 7, 0, 0, 0, 28, 4, 1, 0, 0, 0, 29, 30, 5, 60, 0, 0, 30, 6, 1, 0, 0, 0, 31, 32, 5, 60, 0, 0, 32, 33, 5, 47, 0, 0, 33, 8, 1, 0, 0, 0, 34, 35, 5, 62, 0, 0, 35, 10, 1, 0, 0, 0, 36, 37, 5, 47, 0, 0, 37, 38, 5, 62, 0, 0, 38, 12, 1, 0, 0, 0, 39, 40, 5, 61, 0, 0, 40, 14, 1, 0, 0, 0, 41, 47, 3, 21, 10, 0, 42, 46, 3, 21, 10, 0, 43, 46, 3, 19, 9, 0, 44, 46, 7, 1, 0, 0, 45, 42, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 45, 44, 1, 0, 0, 0, 46, 49, 1, 0, 0, 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 16, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 54, 5, 34, 0, 0, 51, 53, 8, 2, 0, 0, 52, 51, 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 57, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 57, 67, 5, 34, 0, 0, 58, 62, 5, 39, 0, 0, 59, 61, 8, 3, 0, 0, 60, 59, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 65, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 67, 5, 39, 0, 0, 66, 50, 1, 0, 0, 0, 66, 58, 1, 0, 0, 0, 67, 18, 1, 0, 0, 0, 68, 69, 7, 4, 0, 0, 69, 20, 1, 0, 0, 0, 70, 71, 7, 5, 0, 0, 71, 22, 1, 0, 0, 0, 6, 0, 45, 47, 54, 62, 66, 0] \ No newline at end of file diff --git a/src/main/java/controlP5/layout/lang/XMLLexer.java b/src/main/java/controlP5/layout/lang/XMLLexer.java new file mode 100644 index 0000000..5bd5599 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XMLLexer.java @@ -0,0 +1,161 @@ +// Generated from XML.g4 by ANTLR 4.13.0 +package controlP5.layout.lang; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class XMLLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.0", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + SELF_CLOSING=1, SPACE=2, OPEN=3, OPEN_SLASH=4, CLOSE=5, SLASH_CLOSE=6, + EQUALS=7, Name=8, STRING=9; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "SELF_CLOSING", "SPACE", "OPEN", "OPEN_SLASH", "CLOSE", "SLASH_CLOSE", + "EQUALS", "Name", "STRING", "DIGIT", "ALPHA" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, null, null, "'<'", "''", "'/>'", "'='" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "SELF_CLOSING", "SPACE", "OPEN", "OPEN_SLASH", "CLOSE", "SLASH_CLOSE", + "EQUALS", "Name", "STRING" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public XMLLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "XML.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000\tH\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ + "\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+ + "\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+ + "\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0001\u0000"+ + "\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002"+ + "\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004"+ + "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0005\u0007.\b\u0007\n\u0007\f\u0007"+ + "1\t\u0007\u0001\b\u0001\b\u0005\b5\b\b\n\b\f\b8\t\b\u0001\b\u0001\b\u0001"+ + "\b\u0005\b=\b\b\n\b\f\b@\t\b\u0001\b\u0003\bC\b\b\u0001\t\u0001\t\u0001"+ + "\n\u0001\n\u0000\u0000\u000b\u0001\u0001\u0003\u0002\u0005\u0003\u0007"+ + "\u0004\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011\t\u0013\u0000\u0015\u0000"+ + "\u0001\u0000\u0006\u0003\u0000\t\n\r\r \u0002\u0000-.__\u0001\u0000\""+ + "\"\u0001\u0000\'\'\u0001\u000009\u0002\u0000AZazK\u0000\u0001\u0001\u0000"+ + "\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000"+ + "\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000"+ + "\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000"+ + "\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000"+ + "\u0001\u0017\u0001\u0000\u0000\u0000\u0003\u001b\u0001\u0000\u0000\u0000"+ + "\u0005\u001d\u0001\u0000\u0000\u0000\u0007\u001f\u0001\u0000\u0000\u0000"+ + "\t\"\u0001\u0000\u0000\u0000\u000b$\u0001\u0000\u0000\u0000\r\'\u0001"+ + "\u0000\u0000\u0000\u000f)\u0001\u0000\u0000\u0000\u0011B\u0001\u0000\u0000"+ + "\u0000\u0013D\u0001\u0000\u0000\u0000\u0015F\u0001\u0000\u0000\u0000\u0017"+ + "\u0018\u0003\u0005\u0002\u0000\u0018\u0019\u0003\u000f\u0007\u0000\u0019"+ + "\u001a\u0003\u000b\u0005\u0000\u001a\u0002\u0001\u0000\u0000\u0000\u001b"+ + "\u001c\u0007\u0000\u0000\u0000\u001c\u0004\u0001\u0000\u0000\u0000\u001d"+ + "\u001e\u0005<\u0000\u0000\u001e\u0006\u0001\u0000\u0000\u0000\u001f \u0005"+ + "<\u0000\u0000 !\u0005/\u0000\u0000!\b\u0001\u0000\u0000\u0000\"#\u0005"+ + ">\u0000\u0000#\n\u0001\u0000\u0000\u0000$%\u0005/\u0000\u0000%&\u0005"+ + ">\u0000\u0000&\f\u0001\u0000\u0000\u0000\'(\u0005=\u0000\u0000(\u000e"+ + "\u0001\u0000\u0000\u0000)/\u0003\u0015\n\u0000*.\u0003\u0015\n\u0000+"+ + ".\u0003\u0013\t\u0000,.\u0007\u0001\u0000\u0000-*\u0001\u0000\u0000\u0000"+ + "-+\u0001\u0000\u0000\u0000-,\u0001\u0000\u0000\u0000.1\u0001\u0000\u0000"+ + "\u0000/-\u0001\u0000\u0000\u0000/0\u0001\u0000\u0000\u00000\u0010\u0001"+ + "\u0000\u0000\u00001/\u0001\u0000\u0000\u000026\u0005\"\u0000\u000035\b"+ + "\u0002\u0000\u000043\u0001\u0000\u0000\u000058\u0001\u0000\u0000\u0000"+ + "64\u0001\u0000\u0000\u000067\u0001\u0000\u0000\u000079\u0001\u0000\u0000"+ + "\u000086\u0001\u0000\u0000\u00009C\u0005\"\u0000\u0000:>\u0005\'\u0000"+ + "\u0000;=\b\u0003\u0000\u0000<;\u0001\u0000\u0000\u0000=@\u0001\u0000\u0000"+ + "\u0000><\u0001\u0000\u0000\u0000>?\u0001\u0000\u0000\u0000?A\u0001\u0000"+ + "\u0000\u0000@>\u0001\u0000\u0000\u0000AC\u0005\'\u0000\u0000B2\u0001\u0000"+ + "\u0000\u0000B:\u0001\u0000\u0000\u0000C\u0012\u0001\u0000\u0000\u0000"+ + "DE\u0007\u0004\u0000\u0000E\u0014\u0001\u0000\u0000\u0000FG\u0007\u0005"+ + "\u0000\u0000G\u0016\u0001\u0000\u0000\u0000\u0006\u0000-/6>B\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/controlP5/layout/lang/XMLLexer.tokens b/src/main/java/controlP5/layout/lang/XMLLexer.tokens new file mode 100644 index 0000000..f1d8167 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XMLLexer.tokens @@ -0,0 +1,14 @@ +SELF_CLOSING=1 +SPACE=2 +OPEN=3 +OPEN_SLASH=4 +CLOSE=5 +SLASH_CLOSE=6 +EQUALS=7 +Name=8 +STRING=9 +'<'=3 +''=5 +'/>'=6 +'='=7 diff --git a/src/main/java/controlP5/layout/lang/XMLListener.java b/src/main/java/controlP5/layout/lang/XMLListener.java new file mode 100644 index 0000000..d045f82 --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XMLListener.java @@ -0,0 +1,70 @@ +// Generated from XML.g4 by ANTLR 4.13.0 +package controlP5.layout.lang; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link XMLParser}. + */ +public interface XMLListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link XMLParser#document}. + * @param ctx the parse tree + */ + void enterDocument(XMLParser.DocumentContext ctx); + /** + * Exit a parse tree produced by {@link XMLParser#document}. + * @param ctx the parse tree + */ + void exitDocument(XMLParser.DocumentContext ctx); + /** + * Enter a parse tree produced by {@link XMLParser#element}. + * @param ctx the parse tree + */ + void enterElement(XMLParser.ElementContext ctx); + /** + * Exit a parse tree produced by {@link XMLParser#element}. + * @param ctx the parse tree + */ + void exitElement(XMLParser.ElementContext ctx); + /** + * Enter a parse tree produced by {@link XMLParser#startTag}. + * @param ctx the parse tree + */ + void enterStartTag(XMLParser.StartTagContext ctx); + /** + * Exit a parse tree produced by {@link XMLParser#startTag}. + * @param ctx the parse tree + */ + void exitStartTag(XMLParser.StartTagContext ctx); + /** + * Enter a parse tree produced by {@link XMLParser#endTag}. + * @param ctx the parse tree + */ + void enterEndTag(XMLParser.EndTagContext ctx); + /** + * Exit a parse tree produced by {@link XMLParser#endTag}. + * @param ctx the parse tree + */ + void exitEndTag(XMLParser.EndTagContext ctx); + /** + * Enter a parse tree produced by {@link XMLParser#attribute}. + * @param ctx the parse tree + */ + void enterAttribute(XMLParser.AttributeContext ctx); + /** + * Exit a parse tree produced by {@link XMLParser#attribute}. + * @param ctx the parse tree + */ + void exitAttribute(XMLParser.AttributeContext ctx); + /** + * Enter a parse tree produced by {@link XMLParser#content}. + * @param ctx the parse tree + */ + void enterContent(XMLParser.ContentContext ctx); + /** + * Exit a parse tree produced by {@link XMLParser#content}. + * @param ctx the parse tree + */ + void exitContent(XMLParser.ContentContext ctx); +} \ No newline at end of file diff --git a/src/main/java/controlP5/layout/lang/XMLParser.java b/src/main/java/controlP5/layout/lang/XMLParser.java new file mode 100644 index 0000000..108f27e --- /dev/null +++ b/src/main/java/controlP5/layout/lang/XMLParser.java @@ -0,0 +1,490 @@ +// Generated from XML.g4 by ANTLR 4.13.0 +package controlP5.layout.lang; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class XMLParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.0", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + SELF_CLOSING=1, SPACE=2, OPEN=3, OPEN_SLASH=4, CLOSE=5, SLASH_CLOSE=6, + EQUALS=7, Name=8, STRING=9; + public static final int + RULE_document = 0, RULE_element = 1, RULE_startTag = 2, RULE_endTag = 3, + RULE_attribute = 4, RULE_content = 5; + private static String[] makeRuleNames() { + return new String[] { + "document", "element", "startTag", "endTag", "attribute", "content" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, null, null, "'<'", "''", "'/>'", "'='" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "SELF_CLOSING", "SPACE", "OPEN", "OPEN_SLASH", "CLOSE", "SLASH_CLOSE", + "EQUALS", "Name", "STRING" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "XML.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public XMLParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class DocumentContext extends ParserRuleContext { + public ElementContext element() { + return getRuleContext(ElementContext.class,0); + } + public TerminalNode EOF() { return getToken(XMLParser.EOF, 0); } + public DocumentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_document; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).enterDocument(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).exitDocument(this); + } + } + + public final DocumentContext document() throws RecognitionException { + DocumentContext _localctx = new DocumentContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_document); + try { + enterOuterAlt(_localctx, 1); + { + setState(12); + element(); + setState(13); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ElementContext extends ParserRuleContext { + public StartTagContext startTag() { + return getRuleContext(StartTagContext.class,0); + } + public EndTagContext endTag() { + return getRuleContext(EndTagContext.class,0); + } + public List content() { + return getRuleContexts(ContentContext.class); + } + public ContentContext content(int i) { + return getRuleContext(ContentContext.class,i); + } + public List SPACE() { return getTokens(XMLParser.SPACE); } + public TerminalNode SPACE(int i) { + return getToken(XMLParser.SPACE, i); + } + public TerminalNode SELF_CLOSING() { return getToken(XMLParser.SELF_CLOSING, 0); } + public ElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_element; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).enterElement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).exitElement(this); + } + } + + public final ElementContext element() throws RecognitionException { + ElementContext _localctx = new ElementContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_element); + int _la; + try { + setState(26); + _errHandler.sync(this); + switch (_input.LA(1)) { + case OPEN: + enterOuterAlt(_localctx, 1); + { + setState(15); + startTag(); + setState(20); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 526L) != 0)) { + { + setState(18); + _errHandler.sync(this); + switch (_input.LA(1)) { + case SELF_CLOSING: + case OPEN: + case STRING: + { + setState(16); + content(); + } + break; + case SPACE: + { + setState(17); + match(SPACE); + } + break; + default: + throw new NoViableAltException(this); + } + } + setState(22); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(23); + endTag(); + } + break; + case SELF_CLOSING: + enterOuterAlt(_localctx, 2); + { + setState(25); + match(SELF_CLOSING); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StartTagContext extends ParserRuleContext { + public TerminalNode OPEN() { return getToken(XMLParser.OPEN, 0); } + public TerminalNode Name() { return getToken(XMLParser.Name, 0); } + public TerminalNode CLOSE() { return getToken(XMLParser.CLOSE, 0); } + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class,i); + } + public StartTagContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_startTag; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).enterStartTag(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).exitStartTag(this); + } + } + + public final StartTagContext startTag() throws RecognitionException { + StartTagContext _localctx = new StartTagContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_startTag); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(28); + match(OPEN); + setState(29); + match(Name); + setState(33); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==Name) { + { + { + setState(30); + attribute(); + } + } + setState(35); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(36); + match(CLOSE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class EndTagContext extends ParserRuleContext { + public TerminalNode OPEN_SLASH() { return getToken(XMLParser.OPEN_SLASH, 0); } + public TerminalNode Name() { return getToken(XMLParser.Name, 0); } + public TerminalNode CLOSE() { return getToken(XMLParser.CLOSE, 0); } + public EndTagContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_endTag; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).enterEndTag(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).exitEndTag(this); + } + } + + public final EndTagContext endTag() throws RecognitionException { + EndTagContext _localctx = new EndTagContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_endTag); + try { + enterOuterAlt(_localctx, 1); + { + setState(38); + match(OPEN_SLASH); + setState(39); + match(Name); + setState(40); + match(CLOSE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AttributeContext extends ParserRuleContext { + public TerminalNode Name() { return getToken(XMLParser.Name, 0); } + public TerminalNode EQUALS() { return getToken(XMLParser.EQUALS, 0); } + public TerminalNode STRING() { return getToken(XMLParser.STRING, 0); } + public AttributeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_attribute; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).enterAttribute(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).exitAttribute(this); + } + } + + public final AttributeContext attribute() throws RecognitionException { + AttributeContext _localctx = new AttributeContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_attribute); + try { + enterOuterAlt(_localctx, 1); + { + setState(42); + match(Name); + setState(43); + match(EQUALS); + setState(44); + match(STRING); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ContentContext extends ParserRuleContext { + public ElementContext element() { + return getRuleContext(ElementContext.class,0); + } + public TerminalNode STRING() { return getToken(XMLParser.STRING, 0); } + public ContentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_content; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).enterContent(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof XMLListener ) ((XMLListener)listener).exitContent(this); + } + } + + public final ContentContext content() throws RecognitionException { + ContentContext _localctx = new ContentContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_content); + try { + setState(48); + _errHandler.sync(this); + switch (_input.LA(1)) { + case SELF_CLOSING: + case OPEN: + enterOuterAlt(_localctx, 1); + { + setState(46); + element(); + } + break; + case STRING: + enterOuterAlt(_localctx, 2); + { + setState(47); + match(STRING); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\u0004\u0001\t3\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0005\u0001\u0013\b\u0001\n\u0001\f\u0001\u0016\t\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0003\u0001\u001b\b\u0001\u0001\u0002"+ + "\u0001\u0002\u0001\u0002\u0005\u0002 \b\u0002\n\u0002\f\u0002#\t\u0002"+ + "\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+ + "\u0003\u00051\b\u0005\u0001\u0005\u0000\u0000\u0006\u0000\u0002\u0004"+ + "\u0006\b\n\u0000\u00001\u0000\f\u0001\u0000\u0000\u0000\u0002\u001a\u0001"+ + "\u0000\u0000\u0000\u0004\u001c\u0001\u0000\u0000\u0000\u0006&\u0001\u0000"+ + "\u0000\u0000\b*\u0001\u0000\u0000\u0000\n0\u0001\u0000\u0000\u0000\f\r"+ + "\u0003\u0002\u0001\u0000\r\u000e\u0005\u0000\u0000\u0001\u000e\u0001\u0001"+ + "\u0000\u0000\u0000\u000f\u0014\u0003\u0004\u0002\u0000\u0010\u0013\u0003"+ + "\n\u0005\u0000\u0011\u0013\u0005\u0002\u0000\u0000\u0012\u0010\u0001\u0000"+ + "\u0000\u0000\u0012\u0011\u0001\u0000\u0000\u0000\u0013\u0016\u0001\u0000"+ + "\u0000\u0000\u0014\u0012\u0001\u0000\u0000\u0000\u0014\u0015\u0001\u0000"+ + "\u0000\u0000\u0015\u0017\u0001\u0000\u0000\u0000\u0016\u0014\u0001\u0000"+ + "\u0000\u0000\u0017\u0018\u0003\u0006\u0003\u0000\u0018\u001b\u0001\u0000"+ + "\u0000\u0000\u0019\u001b\u0005\u0001\u0000\u0000\u001a\u000f\u0001\u0000"+ + "\u0000\u0000\u001a\u0019\u0001\u0000\u0000\u0000\u001b\u0003\u0001\u0000"+ + "\u0000\u0000\u001c\u001d\u0005\u0003\u0000\u0000\u001d!\u0005\b\u0000"+ + "\u0000\u001e \u0003\b\u0004\u0000\u001f\u001e\u0001\u0000\u0000\u0000"+ + " #\u0001\u0000\u0000\u0000!\u001f\u0001\u0000\u0000\u0000!\"\u0001\u0000"+ + "\u0000\u0000\"$\u0001\u0000\u0000\u0000#!\u0001\u0000\u0000\u0000$%\u0005"+ + "\u0005\u0000\u0000%\u0005\u0001\u0000\u0000\u0000&\'\u0005\u0004\u0000"+ + "\u0000\'(\u0005\b\u0000\u0000()\u0005\u0005\u0000\u0000)\u0007\u0001\u0000"+ + "\u0000\u0000*+\u0005\b\u0000\u0000+,\u0005\u0007\u0000\u0000,-\u0005\t"+ + "\u0000\u0000-\t\u0001\u0000\u0000\u0000.1\u0003\u0002\u0001\u0000/1\u0005"+ + "\t\u0000\u00000.\u0001\u0000\u0000\u00000/\u0001\u0000\u0000\u00001\u000b"+ + "\u0001\u0000\u0000\u0000\u0005\u0012\u0014\u001a!0"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file