All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.daisy.pipeline.css.sass.impl.DoxygenParser Maven / Gradle / Ivy

The newest version!
// $ANTLR 3.5.2 org/daisy/pipeline/css/sass/impl/Doxygen.g 2024-10-03 13:12:09
 package org.daisy.pipeline.css.sass.impl; 

import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

/**
 * Parses a comment in a specific format that is a subset of Doxygen:
 *
 * - Javadoc variant (C-style comment block starting with two *'s,
 *   optionally with intermediate *'s at the beginning of each line)
 * - optionally beginning with @var command:
 *
 *      @var  $
 *
 * - optionally followed by @brief command
 * - followed by a body of Markdown formatted text, with the first
 *   line of the body being plain text (providing the short description)
 *
 * It is assumed that the following preprocessing has been done to the
 * input before it is fed to the lexer:
 *
 * - check that first character is '*'
 * - prepend new line character plus an amount of space characters
     corresponding to the original column of the second '*' of the
     opening '/**'
 * - append new line character
 */
@SuppressWarnings("all")
public class DoxygenParser extends Parser {
	public static final String[] tokenNames = new String[] {
		"", "", "", "", "ANY", "AT_COMMAND", "BRIEF", 
		"CODE_FENCE", "DOLLAR", "EOL", "S", "VAR", "XML_COMMAND_CLOSE", "XML_COMMAND_OPEN"
	};
	public static final int EOF=-1;
	public static final int ANY=4;
	public static final int AT_COMMAND=5;
	public static final int BRIEF=6;
	public static final int CODE_FENCE=7;
	public static final int DOLLAR=8;
	public static final int EOL=9;
	public static final int S=10;
	public static final int VAR=11;
	public static final int XML_COMMAND_CLOSE=12;
	public static final int XML_COMMAND_OPEN=13;

	// delegates
	public Parser[] getDelegates() {
		return new Parser[] {};
	}

	// delegators


	public DoxygenParser(TokenStream input) {
		this(input, new RecognizerSharedState());
	}
	public DoxygenParser(TokenStream input, RecognizerSharedState state) {
		super(input, state);
	}

	@Override public String[] getTokenNames() { return DoxygenParser.tokenNames; }
	@Override public String getGrammarFileName() { return "org/daisy/pipeline/css/sass/impl/Doxygen.g"; }



	    private Comment source;

	    /**
	     * @param source Source of the token stream we are parsing.
	     */
	    public DoxygenParser init(Comment source) {
	        this.source = source;
	        return this;
	    }

	    /* convert XMLStreamReader to Saxon Element */
	    private static org.w3c.dom.Element readElement(javax.xml.stream.XMLStreamReader xml) throws net.sf.saxon.s9api.SaxonApiException,
	                                                                                                net.sf.saxon.trans.XPathException,
	                                                                                                javax.xml.stream.XMLStreamException {
	        net.sf.saxon.s9api.XdmDestination dest = new net.sf.saxon.s9api.XdmDestination();
	        net.sf.saxon.event.Receiver receiver = new net.sf.saxon.event.NamespaceReducer(
	            dest.getReceiver(new net.sf.saxon.s9api.Processor(false).getUnderlyingConfiguration()));
	        receiver.open();
	        org.daisy.common.stax.XMLStreamWriterHelper.writeElement(new net.sf.saxon.event.StreamWriterToReceiver(receiver), xml);
	        return ((org.w3c.dom.Document)net.sf.saxon.dom.DocumentOverNodeInfo.wrap(dest.getXdmNode().getUnderlyingNode())).getDocumentElement();
	    }

	    private static Iterable iterateNodeList(org.w3c.dom.NodeList nodeList) {
	        java.util.List list = new java.util.ArrayList<>();
	        for (int i = 0; i < nodeList.getLength(); i++)
	            list.add(nodeList.item(i));
	        return list;
	    }



	// $ANTLR start "start"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:65:1: start : doxygen_comment ;
	public final void start() throws RecognitionException {
		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:65:7: ( doxygen_comment )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:65:9: doxygen_comment
			{
			pushFollow(FOLLOW_doxygen_comment_in_start44);
			doxygen_comment();
			state._fsp--;

			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
	}
	// $ANTLR end "start"


	protected static class doxygen_comment_scope {
		int bodyIndent;
	}
	protected Stack doxygen_comment_stack = new Stack();


	// $ANTLR start "doxygen_comment"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:67:1: doxygen_comment returns [DoxygenComment comment] : ( EOL )+ ( VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+ )? ( BRIEF S r= rest_of_line ( EOL )+ )? (t=~ ( S | BRIEF | VAR | CODE_FENCE | AT_COMMAND | XML_COMMAND_OPEN | XML_COMMAND_CLOSE | EOL ) text= rest_of_line ( EOL )+ |text= fenced_code_block )+ (d= typedef )? EOF ;
	public final DoxygenComment doxygen_comment() throws RecognitionException {
		doxygen_comment_stack.push(new doxygen_comment_scope());
		DoxygenComment comment = null;


		Token t=null;
		String vt =null;
		String vn =null;
		String r =null;
		String text =null;
		org.w3c.dom.Element d =null;


		    String varName = null;
		    String varType = null;
		    String brief = null;
		    StringBuilder body = new StringBuilder();
		    doxygen_comment_stack.peek().bodyIndent = -1;
		    org.w3c.dom.Element typeDef = null;

		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:92:5: ( ( EOL )+ ( VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+ )? ( BRIEF S r= rest_of_line ( EOL )+ )? (t=~ ( S | BRIEF | VAR | CODE_FENCE | AT_COMMAND | XML_COMMAND_OPEN | XML_COMMAND_CLOSE | EOL ) text= rest_of_line ( EOL )+ |text= fenced_code_block )+ (d= typedef )? EOF )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:92:7: ( EOL )+ ( VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+ )? ( BRIEF S r= rest_of_line ( EOL )+ )? (t=~ ( S | BRIEF | VAR | CODE_FENCE | AT_COMMAND | XML_COMMAND_OPEN | XML_COMMAND_CLOSE | EOL ) text= rest_of_line ( EOL )+ |text= fenced_code_block )+ (d= typedef )? EOF
			{
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:92:7: ( EOL )+
			int cnt1=0;
			loop1:
			while (true) {
				int alt1=2;
				int LA1_0 = input.LA(1);
				if ( (LA1_0==EOL) ) {
					alt1=1;
				}

				switch (alt1) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:92:7: EOL
					{
					match(input,EOL,FOLLOW_EOL_in_doxygen_comment76); 
					}
					break;

				default :
					if ( cnt1 >= 1 ) break loop1;
					EarlyExitException eee = new EarlyExitException(1, input);
					throw eee;
				}
				cnt1++;
			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:7: ( VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+ )?
			int alt5=2;
			int LA5_0 = input.LA(1);
			if ( (LA5_0==VAR) ) {
				alt5=1;
			}
			switch (alt5) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:8: VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+
					{
					match(input,VAR,FOLLOW_VAR_in_doxygen_comment86); 
					match(input,S,FOLLOW_S_in_doxygen_comment88); 
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:14: (vt= var_type S )?
					int alt2=2;
					int LA2_0 = input.LA(1);
					if ( ((LA2_0 >= ANY && LA2_0 <= CODE_FENCE)||(LA2_0 >= VAR && LA2_0 <= XML_COMMAND_OPEN)) ) {
						alt2=1;
					}
					switch (alt2) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:15: vt= var_type S
							{
							pushFollow(FOLLOW_var_type_in_doxygen_comment93);
							vt=var_type();
							state._fsp--;

							 varType = vt; 
							match(input,S,FOLLOW_S_in_doxygen_comment97); 
							}
							break;

					}

					match(input,DOLLAR,FOLLOW_DOLLAR_in_doxygen_comment101); 
					pushFollow(FOLLOW_var_name_in_doxygen_comment105);
					vn=var_name();
					state._fsp--;

					 varName = vn; 
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:86: ( S )?
					int alt3=2;
					int LA3_0 = input.LA(1);
					if ( (LA3_0==S) ) {
						alt3=1;
					}
					switch (alt3) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:86: S
							{
							match(input,S,FOLLOW_S_in_doxygen_comment109); 
							}
							break;

					}

					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:89: ( EOL )+
					int cnt4=0;
					loop4:
					while (true) {
						int alt4=2;
						int LA4_0 = input.LA(1);
						if ( (LA4_0==EOL) ) {
							alt4=1;
						}

						switch (alt4) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:89: EOL
							{
							match(input,EOL,FOLLOW_EOL_in_doxygen_comment112); 
							}
							break;

						default :
							if ( cnt4 >= 1 ) break loop4;
							EarlyExitException eee = new EarlyExitException(4, input);
							throw eee;
						}
						cnt4++;
					}

					}
					break;

			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:7: ( BRIEF S r= rest_of_line ( EOL )+ )?
			int alt7=2;
			int LA7_0 = input.LA(1);
			if ( (LA7_0==BRIEF) ) {
				alt7=1;
			}
			switch (alt7) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:8: BRIEF S r= rest_of_line ( EOL )+
					{
					match(input,BRIEF,FOLLOW_BRIEF_in_doxygen_comment124); 
					match(input,S,FOLLOW_S_in_doxygen_comment126); 
					pushFollow(FOLLOW_rest_of_line_in_doxygen_comment130);
					r=rest_of_line();
					state._fsp--;

					 brief = r; 
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:46: ( EOL )+
					int cnt6=0;
					loop6:
					while (true) {
						int alt6=2;
						int LA6_0 = input.LA(1);
						if ( (LA6_0==EOL) ) {
							alt6=1;
						}

						switch (alt6) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:46: EOL
							{
							match(input,EOL,FOLLOW_EOL_in_doxygen_comment134); 
							}
							break;

						default :
							if ( cnt6 >= 1 ) break loop6;
							EarlyExitException eee = new EarlyExitException(6, input);
							throw eee;
						}
						cnt6++;
					}

					}
					break;

			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:95:7: (t=~ ( S | BRIEF | VAR | CODE_FENCE | AT_COMMAND | XML_COMMAND_OPEN | XML_COMMAND_CLOSE | EOL ) text= rest_of_line ( EOL )+ |text= fenced_code_block )+
			int cnt9=0;
			loop9:
			while (true) {
				int alt9=3;
				int LA9_0 = input.LA(1);
				if ( (LA9_0==ANY||LA9_0==DOLLAR) ) {
					alt9=1;
				}
				else if ( (LA9_0==CODE_FENCE) ) {
					alt9=2;
				}

				switch (alt9) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:96:11: t=~ ( S | BRIEF | VAR | CODE_FENCE | AT_COMMAND | XML_COMMAND_OPEN | XML_COMMAND_CLOSE | EOL ) text= rest_of_line ( EOL )+
					{
					t=input.LT(1);
					if ( input.LA(1)==ANY||input.LA(1)==DOLLAR ) {
						input.consume();
						state.errorRecovery=false;
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}

					              int col = t.getCharPositionInLine();
					              if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
					                  doxygen_comment_stack.peek().bodyIndent = col;
					              for (int k = 0; k < col; k++) body.append(" ");
					              body.append(t.getText());
					          
					pushFollow(FOLLOW_rest_of_line_in_doxygen_comment192);
					text=rest_of_line();
					state._fsp--;

					 body.append(text); 
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:104:11: ( EOL )+
					int cnt8=0;
					loop8:
					while (true) {
						int alt8=2;
						int LA8_0 = input.LA(1);
						if ( (LA8_0==EOL) ) {
							alt8=1;
						}

						switch (alt8) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:104:12: EOL
							{
							match(input,EOL,FOLLOW_EOL_in_doxygen_comment207); 
							 body.append("\n"); 
							}
							break;

						default :
							if ( cnt8 >= 1 ) break loop8;
							EarlyExitException eee = new EarlyExitException(8, input);
							throw eee;
						}
						cnt8++;
					}

					}
					break;
				case 2 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:106:11: text= fenced_code_block
					{
					pushFollow(FOLLOW_fenced_code_block_in_doxygen_comment233);
					text=fenced_code_block();
					state._fsp--;

					 body.append(text); 
					}
					break;

				default :
					if ( cnt9 >= 1 ) break loop9;
					EarlyExitException eee = new EarlyExitException(9, input);
					throw eee;
				}
				cnt9++;
			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:108:7: (d= typedef )?
			int alt10=2;
			int LA10_0 = input.LA(1);
			if ( (LA10_0==XML_COMMAND_OPEN) ) {
				alt10=1;
			}
			switch (alt10) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:108:8: d= typedef
					{
					pushFollow(FOLLOW_typedef_in_doxygen_comment255);
					d=typedef();
					state._fsp--;

					 typeDef = d; 
					}
					break;

			}

			match(input,EOF,FOLLOW_EOF_in_doxygen_comment268); 
			}


			    java.util.Scanner bodyScanner = new java.util.Scanner(body.toString());
			    body = new StringBuilder();
			    if (bodyScanner.hasNextLine())
			        body.append(bodyScanner.nextLine().trim());
			    while (bodyScanner.hasNextLine()) {
			        String line = bodyScanner.nextLine();
			        if (line.length() > doxygen_comment_stack.peek().bodyIndent)
			            line = line.substring(doxygen_comment_stack.peek().bodyIndent);
			        body.append('\n').append(line);
			    }
			    comment = new DoxygenComment(varName, varType, brief, body.toString().trim(), typeDef, source); // throws IllegalArgumentException

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			doxygen_comment_stack.pop();
		}
		return comment;
	}
	// $ANTLR end "doxygen_comment"



	// $ANTLR start "var_type"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:112:1: var_type returns [String type] : (t=~ ( DOLLAR | S | EOL ) )+ ;
	public final String var_type() throws RecognitionException {
		String type = null;


		Token t=null;


		    StringBuilder s = new StringBuilder();

		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:5: ( (t=~ ( DOLLAR | S | EOL ) )+ )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:7: (t=~ ( DOLLAR | S | EOL ) )+
			{
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:7: (t=~ ( DOLLAR | S | EOL ) )+
			int cnt11=0;
			loop11:
			while (true) {
				int alt11=2;
				int LA11_0 = input.LA(1);
				if ( ((LA11_0 >= ANY && LA11_0 <= CODE_FENCE)||(LA11_0 >= VAR && LA11_0 <= XML_COMMAND_OPEN)) ) {
					alt11=1;
				}

				switch (alt11) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:8: t=~ ( DOLLAR | S | EOL )
					{
					t=input.LT(1);
					if ( (input.LA(1) >= ANY && input.LA(1) <= CODE_FENCE)||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
						input.consume();
						state.errorRecovery=false;
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}

					           s.append(t.getText());
					      
					}
					break;

				default :
					if ( cnt11 >= 1 ) break loop11;
					EarlyExitException eee = new EarlyExitException(11, input);
					throw eee;
				}
				cnt11++;
			}

			}


			    type = s.toString();

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
		return type;
	}
	// $ANTLR end "var_type"



	// $ANTLR start "var_name"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:124:1: var_name returns [String name] : (t=~ ( S | EOL ) )+ ;
	public final String var_name() throws RecognitionException {
		String name = null;


		Token t=null;


		    StringBuilder s = new StringBuilder();

		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:5: ( (t=~ ( S | EOL ) )+ )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:7: (t=~ ( S | EOL ) )+
			{
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:7: (t=~ ( S | EOL ) )+
			int cnt12=0;
			loop12:
			while (true) {
				int alt12=2;
				int LA12_0 = input.LA(1);
				if ( ((LA12_0 >= ANY && LA12_0 <= DOLLAR)||(LA12_0 >= VAR && LA12_0 <= XML_COMMAND_OPEN)) ) {
					alt12=1;
				}

				switch (alt12) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:8: t=~ ( S | EOL )
					{
					t=input.LT(1);
					if ( (input.LA(1) >= ANY && input.LA(1) <= DOLLAR)||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
						input.consume();
						state.errorRecovery=false;
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}

					           s.append(t.getText());
					      
					}
					break;

				default :
					if ( cnt12 >= 1 ) break loop12;
					EarlyExitException eee = new EarlyExitException(12, input);
					throw eee;
				}
				cnt12++;
			}

			}


			    name = s.toString();

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
		return name;
	}
	// $ANTLR end "var_name"



	// $ANTLR start "fenced_code_block"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:136:1: fenced_code_block returns [String block] : t= CODE_FENCE text= rest_of_line ( EOL )+ (t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+ )* t= CODE_FENCE ( S )? ( EOL )+ ;
	public final String fenced_code_block() throws RecognitionException {
		String block = null;


		Token t=null;
		String text =null;


		    StringBuilder s = new StringBuilder();

		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:143:5: (t= CODE_FENCE text= rest_of_line ( EOL )+ (t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+ )* t= CODE_FENCE ( S )? ( EOL )+ )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:144:7: t= CODE_FENCE text= rest_of_line ( EOL )+ (t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+ )* t= CODE_FENCE ( S )? ( EOL )+
			{
			t=(Token)match(input,CODE_FENCE,FOLLOW_CODE_FENCE_in_fenced_code_block395); 

			          int col = t.getCharPositionInLine();
			          if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
			              doxygen_comment_stack.peek().bodyIndent = col;
			          for (int k = 0; k < col; k++) s.append(" ");
			          s.append(t.getText());
			      
			pushFollow(FOLLOW_rest_of_line_in_fenced_code_block407);
			text=rest_of_line();
			state._fsp--;

			 s.append(text); 
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:152:7: ( EOL )+
			int cnt13=0;
			loop13:
			while (true) {
				int alt13=2;
				int LA13_0 = input.LA(1);
				if ( (LA13_0==EOL) ) {
					alt13=1;
				}

				switch (alt13) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:152:8: EOL
					{
					match(input,EOL,FOLLOW_EOL_in_fenced_code_block418); 
					 s.append("\n"); 
					}
					break;

				default :
					if ( cnt13 >= 1 ) break loop13;
					EarlyExitException eee = new EarlyExitException(13, input);
					throw eee;
				}
				cnt13++;
			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:153:7: (t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+ )*
			loop15:
			while (true) {
				int alt15=2;
				int LA15_0 = input.LA(1);
				if ( ((LA15_0 >= ANY && LA15_0 <= BRIEF)||LA15_0==DOLLAR||(LA15_0 >= VAR && LA15_0 <= XML_COMMAND_OPEN)) ) {
					alt15=1;
				}

				switch (alt15) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:154:11: t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+
					{
					t=input.LT(1);
					if ( (input.LA(1) >= ANY && input.LA(1) <= BRIEF)||input.LA(1)==DOLLAR||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
						input.consume();
						state.errorRecovery=false;
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}

					              col = t.getCharPositionInLine();
					              if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
					                  doxygen_comment_stack.peek().bodyIndent = col;
					              for (int k = 0; k < col; k++) s.append(" ");
					              s.append(t.getText());
					          
					pushFollow(FOLLOW_rest_of_line_in_fenced_code_block467);
					text=rest_of_line();
					state._fsp--;

					 s.append(text); 
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:162:11: ( EOL )+
					int cnt14=0;
					loop14:
					while (true) {
						int alt14=2;
						int LA14_0 = input.LA(1);
						if ( (LA14_0==EOL) ) {
							alt14=1;
						}

						switch (alt14) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:162:12: EOL
							{
							match(input,EOL,FOLLOW_EOL_in_fenced_code_block482); 
							 s.append("\n"); 
							}
							break;

						default :
							if ( cnt14 >= 1 ) break loop14;
							EarlyExitException eee = new EarlyExitException(14, input);
							throw eee;
						}
						cnt14++;
					}

					}
					break;

				default :
					break loop15;
				}
			}

			t=(Token)match(input,CODE_FENCE,FOLLOW_CODE_FENCE_in_fenced_code_block505); 

			          col = t.getCharPositionInLine();
			          if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
			              doxygen_comment_stack.peek().bodyIndent = col;
			          for (int k = 0; k < col; k++) s.append(" ");
			          s.append(t.getText());
			      
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:171:7: ( S )?
			int alt16=2;
			int LA16_0 = input.LA(1);
			if ( (LA16_0==S) ) {
				alt16=1;
			}
			switch (alt16) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:171:7: S
					{
					match(input,S,FOLLOW_S_in_fenced_code_block515); 
					}
					break;

			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:172:7: ( EOL )+
			int cnt17=0;
			loop17:
			while (true) {
				int alt17=2;
				int LA17_0 = input.LA(1);
				if ( (LA17_0==EOL) ) {
					alt17=1;
				}

				switch (alt17) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:172:8: EOL
					{
					match(input,EOL,FOLLOW_EOL_in_fenced_code_block525); 
					 s.append("\n"); 
					}
					break;

				default :
					if ( cnt17 >= 1 ) break loop17;
					EarlyExitException eee = new EarlyExitException(17, input);
					throw eee;
				}
				cnt17++;
			}

			}


			    block = s.toString();

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
		return block;
	}
	// $ANTLR end "fenced_code_block"



	// $ANTLR start "typedef"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:176:1: typedef returns [org.w3c.dom.Element def] : t= XML_COMMAND_OPEN text= rest_of_line ( EOL )+ (t=~ ( S | EOL ) text= rest_of_line ( EOL )+ )* ;
	public final org.w3c.dom.Element typedef() throws RecognitionException {
		org.w3c.dom.Element def = null;


		Token t=null;
		String text =null;


		    StringBuilder s = new StringBuilder();
		    int indent = -1;

		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:238:5: (t= XML_COMMAND_OPEN text= rest_of_line ( EOL )+ (t=~ ( S | EOL ) text= rest_of_line ( EOL )+ )* )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:238:7: t= XML_COMMAND_OPEN text= rest_of_line ( EOL )+ (t=~ ( S | EOL ) text= rest_of_line ( EOL )+ )*
			{
			t=(Token)match(input,XML_COMMAND_OPEN,FOLLOW_XML_COMMAND_OPEN_in_typedef564); 

			          int col = t.getCharPositionInLine();
			          if (indent < 0 || col < indent) indent = col;
			          for (int k = 0; k < col; k++) s.append(" ");
			          s.append(t.getText());
			      
			pushFollow(FOLLOW_rest_of_line_in_typedef576);
			text=rest_of_line();
			state._fsp--;

			 s.append(text); 
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:245:7: ( EOL )+
			int cnt18=0;
			loop18:
			while (true) {
				int alt18=2;
				int LA18_0 = input.LA(1);
				if ( (LA18_0==EOL) ) {
					alt18=1;
				}

				switch (alt18) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:245:8: EOL
					{
					match(input,EOL,FOLLOW_EOL_in_typedef587); 
					 s.append("\n"); 
					}
					break;

				default :
					if ( cnt18 >= 1 ) break loop18;
					EarlyExitException eee = new EarlyExitException(18, input);
					throw eee;
				}
				cnt18++;
			}

			// org/daisy/pipeline/css/sass/impl/Doxygen.g:246:7: (t=~ ( S | EOL ) text= rest_of_line ( EOL )+ )*
			loop20:
			while (true) {
				int alt20=2;
				int LA20_0 = input.LA(1);
				if ( ((LA20_0 >= ANY && LA20_0 <= DOLLAR)||(LA20_0 >= VAR && LA20_0 <= XML_COMMAND_OPEN)) ) {
					alt20=1;
				}

				switch (alt20) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:247:11: t=~ ( S | EOL ) text= rest_of_line ( EOL )+
					{
					t=input.LT(1);
					if ( (input.LA(1) >= ANY && input.LA(1) <= DOLLAR)||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
						input.consume();
						state.errorRecovery=false;
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}

					              col = t.getCharPositionInLine();
					              if (indent < 0 || col < indent) indent = col;
					              for (int k = 0; k < col; k++) s.append(" ");
					              s.append(t.getText());
					          
					pushFollow(FOLLOW_rest_of_line_in_typedef634);
					text=rest_of_line();
					state._fsp--;

					 s.append(text); 
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:254:11: ( EOL )+
					int cnt19=0;
					loop19:
					while (true) {
						int alt19=2;
						int LA19_0 = input.LA(1);
						if ( (LA19_0==EOL) ) {
							alt19=1;
						}

						switch (alt19) {
						case 1 :
							// org/daisy/pipeline/css/sass/impl/Doxygen.g:254:12: EOL
							{
							match(input,EOL,FOLLOW_EOL_in_typedef649); 
							 s.append("\n"); 
							}
							break;

						default :
							if ( cnt19 >= 1 ) break loop19;
							EarlyExitException eee = new EarlyExitException(19, input);
							throw eee;
						}
						cnt19++;
					}

					}
					break;

				default :
					break loop20;
				}
			}

			}


			    java.util.Scanner scanner = new java.util.Scanner(s.toString());
			    s = new StringBuilder();
			    if (scanner.hasNextLine())
			        s.append(scanner.nextLine().trim());
			    while (scanner.hasNextLine()) {
			        String line = scanner.nextLine();
			        if (line.length() > indent)
			            line = line.substring(indent);
			        s.append('\n').append(line);
			    }
			    try {
			        javax.xml.stream.XMLStreamReader xmlStream
			            = javax.xml.stream.XMLInputFactory.newFactory()
			                                              .createXMLStreamReader(new java.io.StringReader(s.toString()));
			        switch (xmlStream.next()) {
			        case javax.xml.stream.XMLStreamConstants.START_DOCUMENT:
			            xmlStream.next();
			            if (!xmlStream.isStartElement())
			                throw new IllegalStateException(); // should not happen
			        case javax.xml.stream.XMLStreamConstants.START_ELEMENT:
			            if (!new javax.xml.namespace.QName("http://www.daisy.org/ns/pipeline/xproc", "type").equals(xmlStream.getName()))
			                throw new IllegalArgumentException("Unexpected XML command found: " + xmlStream.getName());
			            break;
			        default:
			            throw new IllegalStateException(); // should not happen
			        }
			        for (org.w3c.dom.Node n : iterateNodeList(readElement(xmlStream).getChildNodes())) {
			            switch (n.getNodeType()) {
			            case org.w3c.dom.Node.TEXT_NODE:
			            case org.w3c.dom.Node.CDATA_SECTION_NODE:
			                if (((org.w3c.dom.CharacterData)n).getData().trim().length() > 0)
			                    break;
			                else
			                    continue;
			            case org.w3c.dom.Node.COMMENT_NODE:
			                continue;
			            case org.w3c.dom.Node.ELEMENT_NODE:
			                if (def == null) {
			                    def = (org.w3c.dom.Element)n;
			                    continue;
			                } else
			                    break;
			            default:
			            }
			            throw new IllegalArgumentException("`type' command expects a single child element");
			        }
			        if (xmlStream.hasNext())
			            if (xmlStream.next() != javax.xml.stream.XMLStreamConstants.END_DOCUMENT)
			                throw new IllegalArgumentException("No content allowed after `type' command");
			    } catch (javax.xml.stream.XMLStreamException |
			             java.util.NoSuchElementException |
			             net.sf.saxon.trans.XPathException |
			             net.sf.saxon.s9api.SaxonApiException e) {
			        throw new IllegalArgumentException("Invalid type declaration provided", e);
			    }

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
		return def;
	}
	// $ANTLR end "typedef"



	// $ANTLR start "rest_of_line"
	// org/daisy/pipeline/css/sass/impl/Doxygen.g:258:1: rest_of_line returns [String text] : t= (~ EOL )* ;
	public final String rest_of_line() throws RecognitionException {
		String text = null;


		Token t=null;


		    StringBuilder s = new StringBuilder();

		try {
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:5: (t= (~ EOL )* )
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:7: t= (~ EOL )*
			{
			// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:9: (~ EOL )*
			loop21:
			while (true) {
				int alt21=2;
				int LA21_0 = input.LA(1);
				if ( ((LA21_0 >= ANY && LA21_0 <= DOLLAR)||(LA21_0 >= S && LA21_0 <= XML_COMMAND_OPEN)) ) {
					alt21=1;
				}

				switch (alt21) {
				case 1 :
					// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:10: ~ EOL
					{
					t=input.LT(1);
					if ( (input.LA(1) >= ANY && input.LA(1) <= DOLLAR)||(input.LA(1) >= S && input.LA(1) <= XML_COMMAND_OPEN) ) {
						input.consume();
						state.errorRecovery=false;
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}

					           s.append(t.getText());
					      
					}
					break;

				default :
					break loop21;
				}
			}

			}


			    text = s.toString();

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
		return text;
	}
	// $ANTLR end "rest_of_line"

	// Delegated rules



	public static final BitSet FOLLOW_doxygen_comment_in_start44 = new BitSet(new long[]{0x0000000000000002L});
	public static final BitSet FOLLOW_EOL_in_doxygen_comment76 = new BitSet(new long[]{0x0000000000000BD0L});
	public static final BitSet FOLLOW_VAR_in_doxygen_comment86 = new BitSet(new long[]{0x0000000000000400L});
	public static final BitSet FOLLOW_S_in_doxygen_comment88 = new BitSet(new long[]{0x00000000000039F0L});
	public static final BitSet FOLLOW_var_type_in_doxygen_comment93 = new BitSet(new long[]{0x0000000000000400L});
	public static final BitSet FOLLOW_S_in_doxygen_comment97 = new BitSet(new long[]{0x0000000000000100L});
	public static final BitSet FOLLOW_DOLLAR_in_doxygen_comment101 = new BitSet(new long[]{0x00000000000039F0L});
	public static final BitSet FOLLOW_var_name_in_doxygen_comment105 = new BitSet(new long[]{0x0000000000000600L});
	public static final BitSet FOLLOW_S_in_doxygen_comment109 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_doxygen_comment112 = new BitSet(new long[]{0x00000000000003D0L});
	public static final BitSet FOLLOW_BRIEF_in_doxygen_comment124 = new BitSet(new long[]{0x0000000000000400L});
	public static final BitSet FOLLOW_S_in_doxygen_comment126 = new BitSet(new long[]{0x0000000000003FF0L});
	public static final BitSet FOLLOW_rest_of_line_in_doxygen_comment130 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_doxygen_comment134 = new BitSet(new long[]{0x0000000000000390L});
	public static final BitSet FOLLOW_set_in_doxygen_comment159 = new BitSet(new long[]{0x0000000000003FF0L});
	public static final BitSet FOLLOW_rest_of_line_in_doxygen_comment192 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_doxygen_comment207 = new BitSet(new long[]{0x0000000000002390L});
	public static final BitSet FOLLOW_fenced_code_block_in_doxygen_comment233 = new BitSet(new long[]{0x0000000000002190L});
	public static final BitSet FOLLOW_typedef_in_doxygen_comment255 = new BitSet(new long[]{0x0000000000000000L});
	public static final BitSet FOLLOW_EOF_in_doxygen_comment268 = new BitSet(new long[]{0x0000000000000002L});
	public static final BitSet FOLLOW_set_in_var_type302 = new BitSet(new long[]{0x00000000000038F2L});
	public static final BitSet FOLLOW_set_in_var_name347 = new BitSet(new long[]{0x00000000000039F2L});
	public static final BitSet FOLLOW_CODE_FENCE_in_fenced_code_block395 = new BitSet(new long[]{0x0000000000003FF0L});
	public static final BitSet FOLLOW_rest_of_line_in_fenced_code_block407 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_fenced_code_block418 = new BitSet(new long[]{0x0000000000003BF0L});
	public static final BitSet FOLLOW_set_in_fenced_code_block444 = new BitSet(new long[]{0x0000000000003FF0L});
	public static final BitSet FOLLOW_rest_of_line_in_fenced_code_block467 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_fenced_code_block482 = new BitSet(new long[]{0x0000000000003BF0L});
	public static final BitSet FOLLOW_CODE_FENCE_in_fenced_code_block505 = new BitSet(new long[]{0x0000000000000600L});
	public static final BitSet FOLLOW_S_in_fenced_code_block515 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_fenced_code_block525 = new BitSet(new long[]{0x0000000000000202L});
	public static final BitSet FOLLOW_XML_COMMAND_OPEN_in_typedef564 = new BitSet(new long[]{0x0000000000003FF0L});
	public static final BitSet FOLLOW_rest_of_line_in_typedef576 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_typedef587 = new BitSet(new long[]{0x0000000000003BF2L});
	public static final BitSet FOLLOW_set_in_typedef613 = new BitSet(new long[]{0x0000000000003FF0L});
	public static final BitSet FOLLOW_rest_of_line_in_typedef634 = new BitSet(new long[]{0x0000000000000200L});
	public static final BitSet FOLLOW_EOL_in_typedef649 = new BitSet(new long[]{0x0000000000003BF2L});
	public static final BitSet FOLLOW_set_in_rest_of_line696 = new BitSet(new long[]{0x0000000000003DF2L});
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy