1   // $ANTLR 3.5.2 org/daisy/pipeline/css/sass/impl/Doxygen.g 2025-01-27 18:34:25
2    package org.daisy.pipeline.css.sass.impl; 
3   
4   import org.antlr.runtime.*;
5   import java.util.Stack;
6   import java.util.List;
7   import java.util.ArrayList;
8   
9   /**
10   * Parses a comment in a specific format that is a subset of Doxygen:
11   *
12   * - Javadoc variant (C-style comment block starting with two *'s,
13   *   optionally with intermediate *'s at the beginning of each line)
14   * - optionally beginning with @var command:
15   *
16   *      @var <type> $<var-name>
17   *
18   * - optionally followed by @brief command
19   * - followed by a body of Markdown formatted text, with the first
20   *   line of the body being plain text (providing the short description)
21   *
22   * It is assumed that the following preprocessing has been done to the
23   * input before it is fed to the lexer:
24   *
25   * - check that first character is '*'
26   * - prepend new line character plus an amount of space characters
27       corresponding to the original column of the second '*' of the
28       opening '/**'
29   * - append new line character
30   */
31  @SuppressWarnings("all")
32  public class DoxygenParser extends Parser {
33  	public static final String[] tokenNames = new String[] {
34  		"<invalid>", "<EOR>", "<DOWN>", "<UP>", "ANY", "AT_COMMAND", "BRIEF", 
35  		"CODE_FENCE", "DOLLAR", "EOL", "S", "VAR", "XML_COMMAND_CLOSE", "XML_COMMAND_OPEN"
36  	};
37  	public static final int EOF=-1;
38  	public static final int ANY=4;
39  	public static final int AT_COMMAND=5;
40  	public static final int BRIEF=6;
41  	public static final int CODE_FENCE=7;
42  	public static final int DOLLAR=8;
43  	public static final int EOL=9;
44  	public static final int S=10;
45  	public static final int VAR=11;
46  	public static final int XML_COMMAND_CLOSE=12;
47  	public static final int XML_COMMAND_OPEN=13;
48  
49  	// delegates
50  	public Parser[] getDelegates() {
51  		return new Parser[] {};
52  	}
53  
54  	// delegators
55  
56  
57  	public DoxygenParser(TokenStream input) {
58  		this(input, new RecognizerSharedState());
59  	}
60  	public DoxygenParser(TokenStream input, RecognizerSharedState state) {
61  		super(input, state);
62  	}
63  
64  	@Override public String[] getTokenNames() { return DoxygenParser.tokenNames; }
65  	@Override public String getGrammarFileName() { return "org/daisy/pipeline/css/sass/impl/Doxygen.g"; }
66  
67  
68  
69  	    private Comment source;
70  
71  	    /**
72  	     * @param source Source of the token stream we are parsing.
73  	     */
74  	    public DoxygenParser init(Comment source) {
75  	        this.source = source;
76  	        return this;
77  	    }
78  
79  	    /* convert XMLStreamReader to Saxon Element */
80  	    private static org.w3c.dom.Element readElement(javax.xml.stream.XMLStreamReader xml) throws net.sf.saxon.s9api.SaxonApiException,
81  	                                                                                                net.sf.saxon.trans.XPathException,
82  	                                                                                                javax.xml.stream.XMLStreamException {
83  	        net.sf.saxon.s9api.XdmDestination dest = new net.sf.saxon.s9api.XdmDestination();
84  	        net.sf.saxon.event.Receiver receiver = new net.sf.saxon.event.NamespaceReducer(
85  	            dest.getReceiver(new net.sf.saxon.s9api.Processor(false).getUnderlyingConfiguration()));
86  	        receiver.open();
87  	        org.daisy.common.stax.XMLStreamWriterHelper.writeElement(new net.sf.saxon.event.StreamWriterToReceiver(receiver), xml);
88  	        return ((org.w3c.dom.Document)net.sf.saxon.dom.DocumentOverNodeInfo.wrap(dest.getXdmNode().getUnderlyingNode())).getDocumentElement();
89  	    }
90  
91  	    private static Iterable<org.w3c.dom.Node> iterateNodeList(org.w3c.dom.NodeList nodeList) {
92  	        java.util.List<org.w3c.dom.Node> list = new java.util.ArrayList<>();
93  	        for (int i = 0; i < nodeList.getLength(); i++)
94  	            list.add(nodeList.item(i));
95  	        return list;
96  	    }
97  
98  
99  
100 	// $ANTLR start "start"
101 	// org/daisy/pipeline/css/sass/impl/Doxygen.g:65:1: start : doxygen_comment ;
102 	public final void start() throws RecognitionException {
103 		try {
104 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:65:7: ( doxygen_comment )
105 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:65:9: doxygen_comment
106 			{
107 			pushFollow(FOLLOW_doxygen_comment_in_start44);
108 			doxygen_comment();
109 			state._fsp--;
110 
111 			}
112 
113 		}
114 		catch (RecognitionException re) {
115 			reportError(re);
116 			recover(input,re);
117 		}
118 		finally {
119 			// do for sure before leaving
120 		}
121 	}
122 	// $ANTLR end "start"
123 
124 
125 	protected static class doxygen_comment_scope {
126 		int bodyIndent;
127 	}
128 	protected Stack<doxygen_comment_scope> doxygen_comment_stack = new Stack<doxygen_comment_scope>();
129 
130 
131 	// $ANTLR start "doxygen_comment"
132 	// 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 ;
133 	public final DoxygenComment doxygen_comment() throws RecognitionException {
134 		doxygen_comment_stack.push(new doxygen_comment_scope());
135 		DoxygenComment comment = null;
136 
137 
138 		Token t=null;
139 		String vt =null;
140 		String vn =null;
141 		String r =null;
142 		String text =null;
143 		org.w3c.dom.Element d =null;
144 
145 
146 		    String varName = null;
147 		    String varType = null;
148 		    String brief = null;
149 		    StringBuilder body = new StringBuilder();
150 		    doxygen_comment_stack.peek().bodyIndent = -1;
151 		    org.w3c.dom.Element typeDef = null;
152 
153 		try {
154 			// 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 )
155 			// 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
156 			{
157 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:92:7: ( EOL )+
158 			int cnt1=0;
159 			loop1:
160 			while (true) {
161 				int alt1=2;
162 				int LA1_0 = input.LA(1);
163 				if ( (LA1_0==EOL) ) {
164 					alt1=1;
165 				}
166 
167 				switch (alt1) {
168 				case 1 :
169 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:92:7: EOL
170 					{
171 					match(input,EOL,FOLLOW_EOL_in_doxygen_comment76); 
172 					}
173 					break;
174 
175 				default :
176 					if ( cnt1 >= 1 ) break loop1;
177 					EarlyExitException eee = new EarlyExitException(1, input);
178 					throw eee;
179 				}
180 				cnt1++;
181 			}
182 
183 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:7: ( VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+ )?
184 			int alt5=2;
185 			int LA5_0 = input.LA(1);
186 			if ( (LA5_0==VAR) ) {
187 				alt5=1;
188 			}
189 			switch (alt5) {
190 				case 1 :
191 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:8: VAR S (vt= var_type S )? DOLLAR vn= var_name ( S )? ( EOL )+
192 					{
193 					match(input,VAR,FOLLOW_VAR_in_doxygen_comment86); 
194 					match(input,S,FOLLOW_S_in_doxygen_comment88); 
195 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:14: (vt= var_type S )?
196 					int alt2=2;
197 					int LA2_0 = input.LA(1);
198 					if ( ((LA2_0 >= ANY && LA2_0 <= CODE_FENCE)||(LA2_0 >= VAR && LA2_0 <= XML_COMMAND_OPEN)) ) {
199 						alt2=1;
200 					}
201 					switch (alt2) {
202 						case 1 :
203 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:15: vt= var_type S
204 							{
205 							pushFollow(FOLLOW_var_type_in_doxygen_comment93);
206 							vt=var_type();
207 							state._fsp--;
208 
209 							 varType = vt; 
210 							match(input,S,FOLLOW_S_in_doxygen_comment97); 
211 							}
212 							break;
213 
214 					}
215 
216 					match(input,DOLLAR,FOLLOW_DOLLAR_in_doxygen_comment101); 
217 					pushFollow(FOLLOW_var_name_in_doxygen_comment105);
218 					vn=var_name();
219 					state._fsp--;
220 
221 					 varName = vn; 
222 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:86: ( S )?
223 					int alt3=2;
224 					int LA3_0 = input.LA(1);
225 					if ( (LA3_0==S) ) {
226 						alt3=1;
227 					}
228 					switch (alt3) {
229 						case 1 :
230 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:86: S
231 							{
232 							match(input,S,FOLLOW_S_in_doxygen_comment109); 
233 							}
234 							break;
235 
236 					}
237 
238 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:89: ( EOL )+
239 					int cnt4=0;
240 					loop4:
241 					while (true) {
242 						int alt4=2;
243 						int LA4_0 = input.LA(1);
244 						if ( (LA4_0==EOL) ) {
245 							alt4=1;
246 						}
247 
248 						switch (alt4) {
249 						case 1 :
250 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:93:89: EOL
251 							{
252 							match(input,EOL,FOLLOW_EOL_in_doxygen_comment112); 
253 							}
254 							break;
255 
256 						default :
257 							if ( cnt4 >= 1 ) break loop4;
258 							EarlyExitException eee = new EarlyExitException(4, input);
259 							throw eee;
260 						}
261 						cnt4++;
262 					}
263 
264 					}
265 					break;
266 
267 			}
268 
269 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:7: ( BRIEF S r= rest_of_line ( EOL )+ )?
270 			int alt7=2;
271 			int LA7_0 = input.LA(1);
272 			if ( (LA7_0==BRIEF) ) {
273 				alt7=1;
274 			}
275 			switch (alt7) {
276 				case 1 :
277 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:8: BRIEF S r= rest_of_line ( EOL )+
278 					{
279 					match(input,BRIEF,FOLLOW_BRIEF_in_doxygen_comment124); 
280 					match(input,S,FOLLOW_S_in_doxygen_comment126); 
281 					pushFollow(FOLLOW_rest_of_line_in_doxygen_comment130);
282 					r=rest_of_line();
283 					state._fsp--;
284 
285 					 brief = r; 
286 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:46: ( EOL )+
287 					int cnt6=0;
288 					loop6:
289 					while (true) {
290 						int alt6=2;
291 						int LA6_0 = input.LA(1);
292 						if ( (LA6_0==EOL) ) {
293 							alt6=1;
294 						}
295 
296 						switch (alt6) {
297 						case 1 :
298 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:94:46: EOL
299 							{
300 							match(input,EOL,FOLLOW_EOL_in_doxygen_comment134); 
301 							}
302 							break;
303 
304 						default :
305 							if ( cnt6 >= 1 ) break loop6;
306 							EarlyExitException eee = new EarlyExitException(6, input);
307 							throw eee;
308 						}
309 						cnt6++;
310 					}
311 
312 					}
313 					break;
314 
315 			}
316 
317 			// 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 )+
318 			int cnt9=0;
319 			loop9:
320 			while (true) {
321 				int alt9=3;
322 				int LA9_0 = input.LA(1);
323 				if ( (LA9_0==ANY||LA9_0==DOLLAR) ) {
324 					alt9=1;
325 				}
326 				else if ( (LA9_0==CODE_FENCE) ) {
327 					alt9=2;
328 				}
329 
330 				switch (alt9) {
331 				case 1 :
332 					// 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 )+
333 					{
334 					t=input.LT(1);
335 					if ( input.LA(1)==ANY||input.LA(1)==DOLLAR ) {
336 						input.consume();
337 						state.errorRecovery=false;
338 					}
339 					else {
340 						MismatchedSetException mse = new MismatchedSetException(null,input);
341 						throw mse;
342 					}
343 
344 					              int col = t.getCharPositionInLine();
345 					              if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
346 					                  doxygen_comment_stack.peek().bodyIndent = col;
347 					              for (int k = 0; k < col; k++) body.append(" ");
348 					              body.append(t.getText());
349 					          
350 					pushFollow(FOLLOW_rest_of_line_in_doxygen_comment192);
351 					text=rest_of_line();
352 					state._fsp--;
353 
354 					 body.append(text); 
355 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:104:11: ( EOL )+
356 					int cnt8=0;
357 					loop8:
358 					while (true) {
359 						int alt8=2;
360 						int LA8_0 = input.LA(1);
361 						if ( (LA8_0==EOL) ) {
362 							alt8=1;
363 						}
364 
365 						switch (alt8) {
366 						case 1 :
367 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:104:12: EOL
368 							{
369 							match(input,EOL,FOLLOW_EOL_in_doxygen_comment207); 
370 							 body.append("\n"); 
371 							}
372 							break;
373 
374 						default :
375 							if ( cnt8 >= 1 ) break loop8;
376 							EarlyExitException eee = new EarlyExitException(8, input);
377 							throw eee;
378 						}
379 						cnt8++;
380 					}
381 
382 					}
383 					break;
384 				case 2 :
385 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:106:11: text= fenced_code_block
386 					{
387 					pushFollow(FOLLOW_fenced_code_block_in_doxygen_comment233);
388 					text=fenced_code_block();
389 					state._fsp--;
390 
391 					 body.append(text); 
392 					}
393 					break;
394 
395 				default :
396 					if ( cnt9 >= 1 ) break loop9;
397 					EarlyExitException eee = new EarlyExitException(9, input);
398 					throw eee;
399 				}
400 				cnt9++;
401 			}
402 
403 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:108:7: (d= typedef )?
404 			int alt10=2;
405 			int LA10_0 = input.LA(1);
406 			if ( (LA10_0==XML_COMMAND_OPEN) ) {
407 				alt10=1;
408 			}
409 			switch (alt10) {
410 				case 1 :
411 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:108:8: d= typedef
412 					{
413 					pushFollow(FOLLOW_typedef_in_doxygen_comment255);
414 					d=typedef();
415 					state._fsp--;
416 
417 					 typeDef = d; 
418 					}
419 					break;
420 
421 			}
422 
423 			match(input,EOF,FOLLOW_EOF_in_doxygen_comment268); 
424 			}
425 
426 
427 			    java.util.Scanner bodyScanner = new java.util.Scanner(body.toString());
428 			    body = new StringBuilder();
429 			    if (bodyScanner.hasNextLine())
430 			        body.append(bodyScanner.nextLine().trim());
431 			    while (bodyScanner.hasNextLine()) {
432 			        String line = bodyScanner.nextLine();
433 			        if (line.length() > doxygen_comment_stack.peek().bodyIndent)
434 			            line = line.substring(doxygen_comment_stack.peek().bodyIndent);
435 			        body.append('\n').append(line);
436 			    }
437 			    comment = new DoxygenComment(varName, varType, brief, body.toString().trim(), typeDef, source); // throws IllegalArgumentException
438 
439 		}
440 		catch (RecognitionException re) {
441 			reportError(re);
442 			recover(input,re);
443 		}
444 		finally {
445 			// do for sure before leaving
446 			doxygen_comment_stack.pop();
447 		}
448 		return comment;
449 	}
450 	// $ANTLR end "doxygen_comment"
451 
452 
453 
454 	// $ANTLR start "var_type"
455 	// org/daisy/pipeline/css/sass/impl/Doxygen.g:112:1: var_type returns [String type] : (t=~ ( DOLLAR | S | EOL ) )+ ;
456 	public final String var_type() throws RecognitionException {
457 		String type = null;
458 
459 
460 		Token t=null;
461 
462 
463 		    StringBuilder s = new StringBuilder();
464 
465 		try {
466 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:5: ( (t=~ ( DOLLAR | S | EOL ) )+ )
467 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:7: (t=~ ( DOLLAR | S | EOL ) )+
468 			{
469 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:7: (t=~ ( DOLLAR | S | EOL ) )+
470 			int cnt11=0;
471 			loop11:
472 			while (true) {
473 				int alt11=2;
474 				int LA11_0 = input.LA(1);
475 				if ( ((LA11_0 >= ANY && LA11_0 <= CODE_FENCE)||(LA11_0 >= VAR && LA11_0 <= XML_COMMAND_OPEN)) ) {
476 					alt11=1;
477 				}
478 
479 				switch (alt11) {
480 				case 1 :
481 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:119:8: t=~ ( DOLLAR | S | EOL )
482 					{
483 					t=input.LT(1);
484 					if ( (input.LA(1) >= ANY && input.LA(1) <= CODE_FENCE)||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
485 						input.consume();
486 						state.errorRecovery=false;
487 					}
488 					else {
489 						MismatchedSetException mse = new MismatchedSetException(null,input);
490 						throw mse;
491 					}
492 
493 					           s.append(t.getText());
494 					      
495 					}
496 					break;
497 
498 				default :
499 					if ( cnt11 >= 1 ) break loop11;
500 					EarlyExitException eee = new EarlyExitException(11, input);
501 					throw eee;
502 				}
503 				cnt11++;
504 			}
505 
506 			}
507 
508 
509 			    type = s.toString();
510 
511 		}
512 		catch (RecognitionException re) {
513 			reportError(re);
514 			recover(input,re);
515 		}
516 		finally {
517 			// do for sure before leaving
518 		}
519 		return type;
520 	}
521 	// $ANTLR end "var_type"
522 
523 
524 
525 	// $ANTLR start "var_name"
526 	// org/daisy/pipeline/css/sass/impl/Doxygen.g:124:1: var_name returns [String name] : (t=~ ( S | EOL ) )+ ;
527 	public final String var_name() throws RecognitionException {
528 		String name = null;
529 
530 
531 		Token t=null;
532 
533 
534 		    StringBuilder s = new StringBuilder();
535 
536 		try {
537 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:5: ( (t=~ ( S | EOL ) )+ )
538 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:7: (t=~ ( S | EOL ) )+
539 			{
540 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:7: (t=~ ( S | EOL ) )+
541 			int cnt12=0;
542 			loop12:
543 			while (true) {
544 				int alt12=2;
545 				int LA12_0 = input.LA(1);
546 				if ( ((LA12_0 >= ANY && LA12_0 <= DOLLAR)||(LA12_0 >= VAR && LA12_0 <= XML_COMMAND_OPEN)) ) {
547 					alt12=1;
548 				}
549 
550 				switch (alt12) {
551 				case 1 :
552 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:131:8: t=~ ( S | EOL )
553 					{
554 					t=input.LT(1);
555 					if ( (input.LA(1) >= ANY && input.LA(1) <= DOLLAR)||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
556 						input.consume();
557 						state.errorRecovery=false;
558 					}
559 					else {
560 						MismatchedSetException mse = new MismatchedSetException(null,input);
561 						throw mse;
562 					}
563 
564 					           s.append(t.getText());
565 					      
566 					}
567 					break;
568 
569 				default :
570 					if ( cnt12 >= 1 ) break loop12;
571 					EarlyExitException eee = new EarlyExitException(12, input);
572 					throw eee;
573 				}
574 				cnt12++;
575 			}
576 
577 			}
578 
579 
580 			    name = s.toString();
581 
582 		}
583 		catch (RecognitionException re) {
584 			reportError(re);
585 			recover(input,re);
586 		}
587 		finally {
588 			// do for sure before leaving
589 		}
590 		return name;
591 	}
592 	// $ANTLR end "var_name"
593 
594 
595 
596 	// $ANTLR start "fenced_code_block"
597 	// 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 )+ ;
598 	public final String fenced_code_block() throws RecognitionException {
599 		String block = null;
600 
601 
602 		Token t=null;
603 		String text =null;
604 
605 
606 		    StringBuilder s = new StringBuilder();
607 
608 		try {
609 			// 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 )+ )
610 			// 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 )+
611 			{
612 			t=(Token)match(input,CODE_FENCE,FOLLOW_CODE_FENCE_in_fenced_code_block395); 
613 
614 			          int col = t.getCharPositionInLine();
615 			          if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
616 			              doxygen_comment_stack.peek().bodyIndent = col;
617 			          for (int k = 0; k < col; k++) s.append(" ");
618 			          s.append(t.getText());
619 			      
620 			pushFollow(FOLLOW_rest_of_line_in_fenced_code_block407);
621 			text=rest_of_line();
622 			state._fsp--;
623 
624 			 s.append(text); 
625 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:152:7: ( EOL )+
626 			int cnt13=0;
627 			loop13:
628 			while (true) {
629 				int alt13=2;
630 				int LA13_0 = input.LA(1);
631 				if ( (LA13_0==EOL) ) {
632 					alt13=1;
633 				}
634 
635 				switch (alt13) {
636 				case 1 :
637 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:152:8: EOL
638 					{
639 					match(input,EOL,FOLLOW_EOL_in_fenced_code_block418); 
640 					 s.append("\n"); 
641 					}
642 					break;
643 
644 				default :
645 					if ( cnt13 >= 1 ) break loop13;
646 					EarlyExitException eee = new EarlyExitException(13, input);
647 					throw eee;
648 				}
649 				cnt13++;
650 			}
651 
652 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:153:7: (t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+ )*
653 			loop15:
654 			while (true) {
655 				int alt15=2;
656 				int LA15_0 = input.LA(1);
657 				if ( ((LA15_0 >= ANY && LA15_0 <= BRIEF)||LA15_0==DOLLAR||(LA15_0 >= VAR && LA15_0 <= XML_COMMAND_OPEN)) ) {
658 					alt15=1;
659 				}
660 
661 				switch (alt15) {
662 				case 1 :
663 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:154:11: t=~ ( CODE_FENCE | S | EOL ) text= rest_of_line ( EOL )+
664 					{
665 					t=input.LT(1);
666 					if ( (input.LA(1) >= ANY && input.LA(1) <= BRIEF)||input.LA(1)==DOLLAR||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
667 						input.consume();
668 						state.errorRecovery=false;
669 					}
670 					else {
671 						MismatchedSetException mse = new MismatchedSetException(null,input);
672 						throw mse;
673 					}
674 
675 					              col = t.getCharPositionInLine();
676 					              if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
677 					                  doxygen_comment_stack.peek().bodyIndent = col;
678 					              for (int k = 0; k < col; k++) s.append(" ");
679 					              s.append(t.getText());
680 					          
681 					pushFollow(FOLLOW_rest_of_line_in_fenced_code_block467);
682 					text=rest_of_line();
683 					state._fsp--;
684 
685 					 s.append(text); 
686 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:162:11: ( EOL )+
687 					int cnt14=0;
688 					loop14:
689 					while (true) {
690 						int alt14=2;
691 						int LA14_0 = input.LA(1);
692 						if ( (LA14_0==EOL) ) {
693 							alt14=1;
694 						}
695 
696 						switch (alt14) {
697 						case 1 :
698 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:162:12: EOL
699 							{
700 							match(input,EOL,FOLLOW_EOL_in_fenced_code_block482); 
701 							 s.append("\n"); 
702 							}
703 							break;
704 
705 						default :
706 							if ( cnt14 >= 1 ) break loop14;
707 							EarlyExitException eee = new EarlyExitException(14, input);
708 							throw eee;
709 						}
710 						cnt14++;
711 					}
712 
713 					}
714 					break;
715 
716 				default :
717 					break loop15;
718 				}
719 			}
720 
721 			t=(Token)match(input,CODE_FENCE,FOLLOW_CODE_FENCE_in_fenced_code_block505); 
722 
723 			          col = t.getCharPositionInLine();
724 			          if (doxygen_comment_stack.peek().bodyIndent < 0 || col < doxygen_comment_stack.peek().bodyIndent)
725 			              doxygen_comment_stack.peek().bodyIndent = col;
726 			          for (int k = 0; k < col; k++) s.append(" ");
727 			          s.append(t.getText());
728 			      
729 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:171:7: ( S )?
730 			int alt16=2;
731 			int LA16_0 = input.LA(1);
732 			if ( (LA16_0==S) ) {
733 				alt16=1;
734 			}
735 			switch (alt16) {
736 				case 1 :
737 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:171:7: S
738 					{
739 					match(input,S,FOLLOW_S_in_fenced_code_block515); 
740 					}
741 					break;
742 
743 			}
744 
745 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:172:7: ( EOL )+
746 			int cnt17=0;
747 			loop17:
748 			while (true) {
749 				int alt17=2;
750 				int LA17_0 = input.LA(1);
751 				if ( (LA17_0==EOL) ) {
752 					alt17=1;
753 				}
754 
755 				switch (alt17) {
756 				case 1 :
757 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:172:8: EOL
758 					{
759 					match(input,EOL,FOLLOW_EOL_in_fenced_code_block525); 
760 					 s.append("\n"); 
761 					}
762 					break;
763 
764 				default :
765 					if ( cnt17 >= 1 ) break loop17;
766 					EarlyExitException eee = new EarlyExitException(17, input);
767 					throw eee;
768 				}
769 				cnt17++;
770 			}
771 
772 			}
773 
774 
775 			    block = s.toString();
776 
777 		}
778 		catch (RecognitionException re) {
779 			reportError(re);
780 			recover(input,re);
781 		}
782 		finally {
783 			// do for sure before leaving
784 		}
785 		return block;
786 	}
787 	// $ANTLR end "fenced_code_block"
788 
789 
790 
791 	// $ANTLR start "typedef"
792 	// 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 )+ )* ;
793 	public final org.w3c.dom.Element typedef() throws RecognitionException {
794 		org.w3c.dom.Element def = null;
795 
796 
797 		Token t=null;
798 		String text =null;
799 
800 
801 		    StringBuilder s = new StringBuilder();
802 		    int indent = -1;
803 
804 		try {
805 			// 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 )+ )* )
806 			// 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 )+ )*
807 			{
808 			t=(Token)match(input,XML_COMMAND_OPEN,FOLLOW_XML_COMMAND_OPEN_in_typedef564); 
809 
810 			          int col = t.getCharPositionInLine();
811 			          if (indent < 0 || col < indent) indent = col;
812 			          for (int k = 0; k < col; k++) s.append(" ");
813 			          s.append(t.getText());
814 			      
815 			pushFollow(FOLLOW_rest_of_line_in_typedef576);
816 			text=rest_of_line();
817 			state._fsp--;
818 
819 			 s.append(text); 
820 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:245:7: ( EOL )+
821 			int cnt18=0;
822 			loop18:
823 			while (true) {
824 				int alt18=2;
825 				int LA18_0 = input.LA(1);
826 				if ( (LA18_0==EOL) ) {
827 					alt18=1;
828 				}
829 
830 				switch (alt18) {
831 				case 1 :
832 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:245:8: EOL
833 					{
834 					match(input,EOL,FOLLOW_EOL_in_typedef587); 
835 					 s.append("\n"); 
836 					}
837 					break;
838 
839 				default :
840 					if ( cnt18 >= 1 ) break loop18;
841 					EarlyExitException eee = new EarlyExitException(18, input);
842 					throw eee;
843 				}
844 				cnt18++;
845 			}
846 
847 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:246:7: (t=~ ( S | EOL ) text= rest_of_line ( EOL )+ )*
848 			loop20:
849 			while (true) {
850 				int alt20=2;
851 				int LA20_0 = input.LA(1);
852 				if ( ((LA20_0 >= ANY && LA20_0 <= DOLLAR)||(LA20_0 >= VAR && LA20_0 <= XML_COMMAND_OPEN)) ) {
853 					alt20=1;
854 				}
855 
856 				switch (alt20) {
857 				case 1 :
858 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:247:11: t=~ ( S | EOL ) text= rest_of_line ( EOL )+
859 					{
860 					t=input.LT(1);
861 					if ( (input.LA(1) >= ANY && input.LA(1) <= DOLLAR)||(input.LA(1) >= VAR && input.LA(1) <= XML_COMMAND_OPEN) ) {
862 						input.consume();
863 						state.errorRecovery=false;
864 					}
865 					else {
866 						MismatchedSetException mse = new MismatchedSetException(null,input);
867 						throw mse;
868 					}
869 
870 					              col = t.getCharPositionInLine();
871 					              if (indent < 0 || col < indent) indent = col;
872 					              for (int k = 0; k < col; k++) s.append(" ");
873 					              s.append(t.getText());
874 					          
875 					pushFollow(FOLLOW_rest_of_line_in_typedef634);
876 					text=rest_of_line();
877 					state._fsp--;
878 
879 					 s.append(text); 
880 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:254:11: ( EOL )+
881 					int cnt19=0;
882 					loop19:
883 					while (true) {
884 						int alt19=2;
885 						int LA19_0 = input.LA(1);
886 						if ( (LA19_0==EOL) ) {
887 							alt19=1;
888 						}
889 
890 						switch (alt19) {
891 						case 1 :
892 							// org/daisy/pipeline/css/sass/impl/Doxygen.g:254:12: EOL
893 							{
894 							match(input,EOL,FOLLOW_EOL_in_typedef649); 
895 							 s.append("\n"); 
896 							}
897 							break;
898 
899 						default :
900 							if ( cnt19 >= 1 ) break loop19;
901 							EarlyExitException eee = new EarlyExitException(19, input);
902 							throw eee;
903 						}
904 						cnt19++;
905 					}
906 
907 					}
908 					break;
909 
910 				default :
911 					break loop20;
912 				}
913 			}
914 
915 			}
916 
917 
918 			    java.util.Scanner scanner = new java.util.Scanner(s.toString());
919 			    s = new StringBuilder();
920 			    if (scanner.hasNextLine())
921 			        s.append(scanner.nextLine().trim());
922 			    while (scanner.hasNextLine()) {
923 			        String line = scanner.nextLine();
924 			        if (line.length() > indent)
925 			            line = line.substring(indent);
926 			        s.append('\n').append(line);
927 			    }
928 			    try {
929 			        javax.xml.stream.XMLStreamReader xmlStream
930 			            = javax.xml.stream.XMLInputFactory.newFactory()
931 			                                              .createXMLStreamReader(new java.io.StringReader(s.toString()));
932 			        switch (xmlStream.next()) {
933 			        case javax.xml.stream.XMLStreamConstants.START_DOCUMENT:
934 			            xmlStream.next();
935 			            if (!xmlStream.isStartElement())
936 			                throw new IllegalStateException(); // should not happen
937 			        case javax.xml.stream.XMLStreamConstants.START_ELEMENT:
938 			            if (!new javax.xml.namespace.QName("http://www.daisy.org/ns/pipeline/xproc", "type").equals(xmlStream.getName()))
939 			                throw new IllegalArgumentException("Unexpected XML command found: " + xmlStream.getName());
940 			            break;
941 			        default:
942 			            throw new IllegalStateException(); // should not happen
943 			        }
944 			        for (org.w3c.dom.Node n : iterateNodeList(readElement(xmlStream).getChildNodes())) {
945 			            switch (n.getNodeType()) {
946 			            case org.w3c.dom.Node.TEXT_NODE:
947 			            case org.w3c.dom.Node.CDATA_SECTION_NODE:
948 			                if (((org.w3c.dom.CharacterData)n).getData().trim().length() > 0)
949 			                    break;
950 			                else
951 			                    continue;
952 			            case org.w3c.dom.Node.COMMENT_NODE:
953 			                continue;
954 			            case org.w3c.dom.Node.ELEMENT_NODE:
955 			                if (def == null) {
956 			                    def = (org.w3c.dom.Element)n;
957 			                    continue;
958 			                } else
959 			                    break;
960 			            default:
961 			            }
962 			            throw new IllegalArgumentException("`type' command expects a single child element");
963 			        }
964 			        if (xmlStream.hasNext())
965 			            if (xmlStream.next() != javax.xml.stream.XMLStreamConstants.END_DOCUMENT)
966 			                throw new IllegalArgumentException("No content allowed after `type' command");
967 			    } catch (javax.xml.stream.XMLStreamException |
968 			             java.util.NoSuchElementException |
969 			             net.sf.saxon.trans.XPathException |
970 			             net.sf.saxon.s9api.SaxonApiException e) {
971 			        throw new IllegalArgumentException("Invalid type declaration provided", e);
972 			    }
973 
974 		}
975 		catch (RecognitionException re) {
976 			reportError(re);
977 			recover(input,re);
978 		}
979 		finally {
980 			// do for sure before leaving
981 		}
982 		return def;
983 	}
984 	// $ANTLR end "typedef"
985 
986 
987 
988 	// $ANTLR start "rest_of_line"
989 	// org/daisy/pipeline/css/sass/impl/Doxygen.g:258:1: rest_of_line returns [String text] : t= (~ EOL )* ;
990 	public final String rest_of_line() throws RecognitionException {
991 		String text = null;
992 
993 
994 		Token t=null;
995 
996 
997 		    StringBuilder s = new StringBuilder();
998 
999 		try {
1000 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:5: (t= (~ EOL )* )
1001 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:7: t= (~ EOL )*
1002 			{
1003 			// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:9: (~ EOL )*
1004 			loop21:
1005 			while (true) {
1006 				int alt21=2;
1007 				int LA21_0 = input.LA(1);
1008 				if ( ((LA21_0 >= ANY && LA21_0 <= DOLLAR)||(LA21_0 >= S && LA21_0 <= XML_COMMAND_OPEN)) ) {
1009 					alt21=1;
1010 				}
1011 
1012 				switch (alt21) {
1013 				case 1 :
1014 					// org/daisy/pipeline/css/sass/impl/Doxygen.g:265:10: ~ EOL
1015 					{
1016 					t=input.LT(1);
1017 					if ( (input.LA(1) >= ANY && input.LA(1) <= DOLLAR)||(input.LA(1) >= S && input.LA(1) <= XML_COMMAND_OPEN) ) {
1018 						input.consume();
1019 						state.errorRecovery=false;
1020 					}
1021 					else {
1022 						MismatchedSetException mse = new MismatchedSetException(null,input);
1023 						throw mse;
1024 					}
1025 
1026 					           s.append(t.getText());
1027 					      
1028 					}
1029 					break;
1030 
1031 				default :
1032 					break loop21;
1033 				}
1034 			}
1035 
1036 			}
1037 
1038 
1039 			    text = s.toString();
1040 
1041 		}
1042 		catch (RecognitionException re) {
1043 			reportError(re);
1044 			recover(input,re);
1045 		}
1046 		finally {
1047 			// do for sure before leaving
1048 		}
1049 		return text;
1050 	}
1051 	// $ANTLR end "rest_of_line"
1052 
1053 	// Delegated rules
1054 
1055 
1056 
1057 	public static final BitSet FOLLOW_doxygen_comment_in_start44 = new BitSet(new long[]{0x0000000000000002L});
1058 	public static final BitSet FOLLOW_EOL_in_doxygen_comment76 = new BitSet(new long[]{0x0000000000000BD0L});
1059 	public static final BitSet FOLLOW_VAR_in_doxygen_comment86 = new BitSet(new long[]{0x0000000000000400L});
1060 	public static final BitSet FOLLOW_S_in_doxygen_comment88 = new BitSet(new long[]{0x00000000000039F0L});
1061 	public static final BitSet FOLLOW_var_type_in_doxygen_comment93 = new BitSet(new long[]{0x0000000000000400L});
1062 	public static final BitSet FOLLOW_S_in_doxygen_comment97 = new BitSet(new long[]{0x0000000000000100L});
1063 	public static final BitSet FOLLOW_DOLLAR_in_doxygen_comment101 = new BitSet(new long[]{0x00000000000039F0L});
1064 	public static final BitSet FOLLOW_var_name_in_doxygen_comment105 = new BitSet(new long[]{0x0000000000000600L});
1065 	public static final BitSet FOLLOW_S_in_doxygen_comment109 = new BitSet(new long[]{0x0000000000000200L});
1066 	public static final BitSet FOLLOW_EOL_in_doxygen_comment112 = new BitSet(new long[]{0x00000000000003D0L});
1067 	public static final BitSet FOLLOW_BRIEF_in_doxygen_comment124 = new BitSet(new long[]{0x0000000000000400L});
1068 	public static final BitSet FOLLOW_S_in_doxygen_comment126 = new BitSet(new long[]{0x0000000000003FF0L});
1069 	public static final BitSet FOLLOW_rest_of_line_in_doxygen_comment130 = new BitSet(new long[]{0x0000000000000200L});
1070 	public static final BitSet FOLLOW_EOL_in_doxygen_comment134 = new BitSet(new long[]{0x0000000000000390L});
1071 	public static final BitSet FOLLOW_set_in_doxygen_comment159 = new BitSet(new long[]{0x0000000000003FF0L});
1072 	public static final BitSet FOLLOW_rest_of_line_in_doxygen_comment192 = new BitSet(new long[]{0x0000000000000200L});
1073 	public static final BitSet FOLLOW_EOL_in_doxygen_comment207 = new BitSet(new long[]{0x0000000000002390L});
1074 	public static final BitSet FOLLOW_fenced_code_block_in_doxygen_comment233 = new BitSet(new long[]{0x0000000000002190L});
1075 	public static final BitSet FOLLOW_typedef_in_doxygen_comment255 = new BitSet(new long[]{0x0000000000000000L});
1076 	public static final BitSet FOLLOW_EOF_in_doxygen_comment268 = new BitSet(new long[]{0x0000000000000002L});
1077 	public static final BitSet FOLLOW_set_in_var_type302 = new BitSet(new long[]{0x00000000000038F2L});
1078 	public static final BitSet FOLLOW_set_in_var_name347 = new BitSet(new long[]{0x00000000000039F2L});
1079 	public static final BitSet FOLLOW_CODE_FENCE_in_fenced_code_block395 = new BitSet(new long[]{0x0000000000003FF0L});
1080 	public static final BitSet FOLLOW_rest_of_line_in_fenced_code_block407 = new BitSet(new long[]{0x0000000000000200L});
1081 	public static final BitSet FOLLOW_EOL_in_fenced_code_block418 = new BitSet(new long[]{0x0000000000003BF0L});
1082 	public static final BitSet FOLLOW_set_in_fenced_code_block444 = new BitSet(new long[]{0x0000000000003FF0L});
1083 	public static final BitSet FOLLOW_rest_of_line_in_fenced_code_block467 = new BitSet(new long[]{0x0000000000000200L});
1084 	public static final BitSet FOLLOW_EOL_in_fenced_code_block482 = new BitSet(new long[]{0x0000000000003BF0L});
1085 	public static final BitSet FOLLOW_CODE_FENCE_in_fenced_code_block505 = new BitSet(new long[]{0x0000000000000600L});
1086 	public static final BitSet FOLLOW_S_in_fenced_code_block515 = new BitSet(new long[]{0x0000000000000200L});
1087 	public static final BitSet FOLLOW_EOL_in_fenced_code_block525 = new BitSet(new long[]{0x0000000000000202L});
1088 	public static final BitSet FOLLOW_XML_COMMAND_OPEN_in_typedef564 = new BitSet(new long[]{0x0000000000003FF0L});
1089 	public static final BitSet FOLLOW_rest_of_line_in_typedef576 = new BitSet(new long[]{0x0000000000000200L});
1090 	public static final BitSet FOLLOW_EOL_in_typedef587 = new BitSet(new long[]{0x0000000000003BF2L});
1091 	public static final BitSet FOLLOW_set_in_typedef613 = new BitSet(new long[]{0x0000000000003FF0L});
1092 	public static final BitSet FOLLOW_rest_of_line_in_typedef634 = new BitSet(new long[]{0x0000000000000200L});
1093 	public static final BitSet FOLLOW_EOL_in_typedef649 = new BitSet(new long[]{0x0000000000003BF2L});
1094 	public static final BitSet FOLLOW_set_in_rest_of_line696 = new BitSet(new long[]{0x0000000000003DF2L});
1095 }