org.daisy.pipeline.css.sass.impl.SassDocumentationParser Maven / Gradle / Ivy
The newest version!
// $ANTLR 3.5.2 org/daisy/pipeline/css/sass/impl/SassDocumentation.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 SCSS file and extracts information about variables. It
* does this by parsing variable declarations and their preceding
* comments. The comments are expected to be in a specific format that
* is a subset of Doxygen.
*
* The information gathering could later be extended to other elements
* such as functions and mixins.
*/
@SuppressWarnings("all")
public class SassDocumentationParser extends Parser {
public static final String[] tokenNames = new String[] {
"", "", "", "", "ANY", "APOS", "AT", "BANG", "COLON",
"COMMA", "COMMENT", "COMMENT_MACR", "DEFAULT", "DOLLAR", "ESCAPE_CHAR",
"IDENT", "IDENT_START", "IMPORT", "LCURLY", "LINE_COMMENT", "MEDIA", "MINUS",
"NAME_CHAR", "NEWLINE_CHAR", "NON_ASCII", "QUOT", "RCURLY", "S", "SEMICOLON",
"SPACE_CHAR", "STRING", "STRING_CHAR", "STRING_MACR", "URI", "URI_CHAR",
"URI_MACR", "VAR_DECL", "XML_COMMENT_CLOSE", "XML_COMMENT_OPEN"
};
public static final int EOF=-1;
public static final int ANY=4;
public static final int APOS=5;
public static final int AT=6;
public static final int BANG=7;
public static final int COLON=8;
public static final int COMMA=9;
public static final int COMMENT=10;
public static final int COMMENT_MACR=11;
public static final int DEFAULT=12;
public static final int DOLLAR=13;
public static final int ESCAPE_CHAR=14;
public static final int IDENT=15;
public static final int IDENT_START=16;
public static final int IMPORT=17;
public static final int LCURLY=18;
public static final int LINE_COMMENT=19;
public static final int MEDIA=20;
public static final int MINUS=21;
public static final int NAME_CHAR=22;
public static final int NEWLINE_CHAR=23;
public static final int NON_ASCII=24;
public static final int QUOT=25;
public static final int RCURLY=26;
public static final int S=27;
public static final int SEMICOLON=28;
public static final int SPACE_CHAR=29;
public static final int STRING=30;
public static final int STRING_CHAR=31;
public static final int STRING_MACR=32;
public static final int URI=33;
public static final int URI_CHAR=34;
public static final int URI_MACR=35;
public static final int VAR_DECL=36;
public static final int XML_COMMENT_CLOSE=37;
public static final int XML_COMMENT_OPEN=38;
// delegates
public Parser[] getDelegates() {
return new Parser[] {};
}
// delegators
public SassDocumentationParser(TokenStream input) {
this(input, new RecognizerSharedState());
}
public SassDocumentationParser(TokenStream input, RecognizerSharedState state) {
super(input, state);
}
@Override public String[] getTokenNames() { return SassDocumentationParser.tokenNames; }
@Override public String getGrammarFileName() { return "org/daisy/pipeline/css/sass/impl/SassDocumentation.g"; }
private boolean isScss;
private java.net.URI base;
private java.util.Collection media;
private SassAnalyzer analyzer;
private org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
/**
* @param base for resolving imports
* @param analyzer for handling imports
*/
public SassDocumentationParser init(boolean isScss,
java.net.URI base,
java.util.Collection media,
SassAnalyzer analyzer) {
this.isScss = isScss;
this.base = base;
this.media = media;
this.analyzer = analyzer;
return this;
}
private boolean matchingMedia(String mediaQuery) {
return com.google.common.collect.Iterables.any(media, m -> m.matches(mediaQuery));
}
// $ANTLR start "start"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:49:1: start : variables ;
public final void start() throws RecognitionException {
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:49:7: ( variables )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:49:9: variables
{
pushFollow(FOLLOW_variables_in_start44);
variables();
state._fsp--;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
}
// $ANTLR end "start"
// $ANTLR start "variables"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:51:1: variables returns [java.util.Collection vars] : (c= comment | (n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON ) |vars_from_import= import_rule |vars_inside_media= media_rule | rule_block |~ ( COMMENT | VAR_DECL | IMPORT | MEDIA | LCURLY | RCURLY | S ) | S )* ;
public final java.util.Collection variables() throws RecognitionException {
java.util.Collection vars = null;
Token n=null;
Comment c =null;
String v =null;
java.util.Collection vars_from_import =null;
java.util.Collection vars_inside_media =null;
Comment lastComment = null;
vars = new java.util.ArrayList<>();
boolean isDefault = false;
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:57:5: ( (c= comment | (n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON ) |vars_from_import= import_rule |vars_inside_media= media_rule | rule_block |~ ( COMMENT | VAR_DECL | IMPORT | MEDIA | LCURLY | RCURLY | S ) | S )* )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:57:7: (c= comment | (n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON ) |vars_from_import= import_rule |vars_inside_media= media_rule | rule_block |~ ( COMMENT | VAR_DECL | IMPORT | MEDIA | LCURLY | RCURLY | S ) | S )*
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:57:7: (c= comment | (n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON ) |vars_from_import= import_rule |vars_inside_media= media_rule | rule_block |~ ( COMMENT | VAR_DECL | IMPORT | MEDIA | LCURLY | RCURLY | S ) | S )*
loop3:
while (true) {
int alt3=8;
switch ( input.LA(1) ) {
case COMMENT:
{
alt3=1;
}
break;
case VAR_DECL:
{
alt3=2;
}
break;
case IMPORT:
{
alt3=3;
}
break;
case MEDIA:
{
alt3=4;
}
break;
case LCURLY:
{
alt3=5;
}
break;
case ANY:
case APOS:
case AT:
case BANG:
case COLON:
case COMMA:
case COMMENT_MACR:
case DEFAULT:
case DOLLAR:
case ESCAPE_CHAR:
case IDENT:
case IDENT_START:
case LINE_COMMENT:
case MINUS:
case NAME_CHAR:
case NEWLINE_CHAR:
case NON_ASCII:
case QUOT:
case SEMICOLON:
case SPACE_CHAR:
case STRING:
case STRING_CHAR:
case STRING_MACR:
case URI:
case URI_CHAR:
case URI_MACR:
case XML_COMMENT_CLOSE:
case XML_COMMENT_OPEN:
{
alt3=6;
}
break;
case S:
{
alt3=7;
}
break;
}
switch (alt3) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:57:9: c= comment
{
pushFollow(FOLLOW_comment_in_variables71);
c=comment();
state._fsp--;
lastComment = c;
}
break;
case 2 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:9: (n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON )
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:9: (n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:10: n= VAR_DECL v= variable_value ( DEFAULT ( S )? )? SEMICOLON
{
n=(Token)match(input,VAR_DECL,FOLLOW_VAR_DECL_in_variables86);
isDefault = false;
pushFollow(FOLLOW_variable_value_in_variables92);
v=variable_value();
state._fsp--;
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:61: ( DEFAULT ( S )? )?
int alt2=2;
int LA2_0 = input.LA(1);
if ( (LA2_0==DEFAULT) ) {
alt2=1;
}
switch (alt2) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:62: DEFAULT ( S )?
{
match(input,DEFAULT,FOLLOW_DEFAULT_in_variables95);
isDefault = true;
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:91: ( S )?
int alt1=2;
int LA1_0 = input.LA(1);
if ( (LA1_0==S) ) {
alt1=1;
}
switch (alt1) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:58:91: S
{
match(input,S,FOLLOW_S_in_variables99);
}
break;
}
}
break;
}
match(input,SEMICOLON,FOLLOW_SEMICOLON_in_variables104);
}
String name = n.getText().substring(1, n.getText().length() - 1).trim();
if (isDefault)
vars.add(new SassVariable(name, lastComment, v, analyzer.datatypes));
else
vars.add(new SassVariable(name, v));
lastComment = null;
}
break;
case 3 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:67:9: vars_from_import= import_rule
{
pushFollow(FOLLOW_import_rule_in_variables126);
vars_from_import=import_rule();
state._fsp--;
vars.addAll(vars_from_import);
lastComment = null;
}
break;
case 4 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:71:9: vars_inside_media= media_rule
{
pushFollow(FOLLOW_media_rule_in_variables140);
vars_inside_media=media_rule();
state._fsp--;
if (vars_inside_media != null)
vars.addAll(vars_inside_media);
lastComment = null;
}
break;
case 5 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:76:9: rule_block
{
pushFollow(FOLLOW_rule_block_in_variables152);
rule_block();
state._fsp--;
lastComment = null;
}
break;
case 6 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:77:9: ~ ( COMMENT | VAR_DECL | IMPORT | MEDIA | LCURLY | RCURLY | S )
{
if ( (input.LA(1) >= ANY && input.LA(1) <= COMMA)||(input.LA(1) >= COMMENT_MACR && input.LA(1) <= IDENT_START)||input.LA(1)==LINE_COMMENT||(input.LA(1) >= MINUS && input.LA(1) <= QUOT)||(input.LA(1) >= SEMICOLON && input.LA(1) <= URI_MACR)||(input.LA(1) >= XML_COMMENT_CLOSE && input.LA(1) <= XML_COMMENT_OPEN) ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
lastComment = null;
}
break;
case 7 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:78:9: S
{
match(input,S,FOLLOW_S_in_variables191);
}
break;
default :
break loop3;
}
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return vars;
}
// $ANTLR end "variables"
// $ANTLR start "variable_value"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:82:1: variable_value returns [String value] : (t=~ ( DEFAULT | SEMICOLON ) )+ ;
public final String variable_value() throws RecognitionException {
String value = null;
Token t=null;
value = "";
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:89:5: ( (t=~ ( DEFAULT | SEMICOLON ) )+ )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:89:7: (t=~ ( DEFAULT | SEMICOLON ) )+
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:89:7: (t=~ ( DEFAULT | SEMICOLON ) )+
int cnt4=0;
loop4:
while (true) {
int alt4=2;
int LA4_0 = input.LA(1);
if ( ((LA4_0 >= ANY && LA4_0 <= COMMENT_MACR)||(LA4_0 >= DOLLAR && LA4_0 <= S)||(LA4_0 >= SPACE_CHAR && LA4_0 <= XML_COMMENT_OPEN)) ) {
alt4=1;
}
switch (alt4) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:89:9: t=~ ( DEFAULT | SEMICOLON )
{
t=input.LT(1);
if ( (input.LA(1) >= ANY && input.LA(1) <= COMMENT_MACR)||(input.LA(1) >= DOLLAR && input.LA(1) <= S)||(input.LA(1) >= SPACE_CHAR && input.LA(1) <= XML_COMMENT_OPEN) ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
value += t.getText();
}
break;
default :
if ( cnt4 >= 1 ) break loop4;
EarlyExitException eee = new EarlyExitException(4, input);
throw eee;
}
cnt4++;
}
}
value = value.trim();
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return value;
}
// $ANTLR end "variable_value"
// $ANTLR start "comment"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:92:1: comment returns [Comment comment] : c= COMMENT ;
public final Comment comment() throws RecognitionException {
Comment comment = null;
Token c=null;
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:93:5: (c= COMMENT )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:93:7: c= COMMENT
{
c=(Token)match(input,COMMENT,FOLLOW_COMMENT_in_comment268);
String text = c.getText();
comment = new Comment(text.substring(2, text.length() - 2), c.getCharPositionInLine());
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return comment;
}
// $ANTLR end "comment"
// $ANTLR start "import_rule"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:99:1: import_rule returns [java.util.Collection vars] : ( IMPORT ( S )? u= import_uri ( ( S )? COMMA ( S )? u= import_uri )* ( S )? (q= media )? SEMICOLON ) ;
public final java.util.Collection import_rule() throws RecognitionException {
java.util.Collection vars = null;
java.net.URI u =null;
String q =null;
vars = new java.util.ArrayList<>();
java.util.List imports = new java.util.ArrayList<>();
String mediaQuery = null;
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:105:5: ( ( IMPORT ( S )? u= import_uri ( ( S )? COMMA ( S )? u= import_uri )* ( S )? (q= media )? SEMICOLON ) )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:105:7: ( IMPORT ( S )? u= import_uri ( ( S )? COMMA ( S )? u= import_uri )* ( S )? (q= media )? SEMICOLON )
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:105:7: ( IMPORT ( S )? u= import_uri ( ( S )? COMMA ( S )? u= import_uri )* ( S )? (q= media )? SEMICOLON )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:105:8: IMPORT ( S )? u= import_uri ( ( S )? COMMA ( S )? u= import_uri )* ( S )? (q= media )? SEMICOLON
{
match(input,IMPORT,FOLLOW_IMPORT_in_import_rule297);
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:106:8: ( S )?
int alt5=2;
int LA5_0 = input.LA(1);
if ( (LA5_0==S) ) {
alt5=1;
}
switch (alt5) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:106:8: S
{
match(input,S,FOLLOW_S_in_import_rule306);
}
break;
}
pushFollow(FOLLOW_import_uri_in_import_rule311);
u=import_uri();
state._fsp--;
imports.add(u);
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:107:8: ( ( S )? COMMA ( S )? u= import_uri )*
loop8:
while (true) {
int alt8=2;
int LA8_0 = input.LA(1);
if ( (LA8_0==S) ) {
int LA8_1 = input.LA(2);
if ( (LA8_1==COMMA) ) {
alt8=1;
}
}
else if ( (LA8_0==COMMA) ) {
alt8=1;
}
switch (alt8) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:107:9: ( S )? COMMA ( S )? u= import_uri
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:107:9: ( S )?
int alt6=2;
int LA6_0 = input.LA(1);
if ( (LA6_0==S) ) {
alt6=1;
}
switch (alt6) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:107:9: S
{
match(input,S,FOLLOW_S_in_import_rule323);
}
break;
}
match(input,COMMA,FOLLOW_COMMA_in_import_rule326);
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:107:18: ( S )?
int alt7=2;
int LA7_0 = input.LA(1);
if ( (LA7_0==S) ) {
alt7=1;
}
switch (alt7) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:107:18: S
{
match(input,S,FOLLOW_S_in_import_rule328);
}
break;
}
pushFollow(FOLLOW_import_uri_in_import_rule333);
u=import_uri();
state._fsp--;
imports.add(u);
}
break;
default :
break loop8;
}
}
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:108:8: ( S )?
int alt9=2;
int LA9_0 = input.LA(1);
if ( (LA9_0==S) ) {
alt9=1;
}
switch (alt9) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:108:8: S
{
match(input,S,FOLLOW_S_in_import_rule346);
}
break;
}
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:108:11: (q= media )?
int alt10=2;
int LA10_0 = input.LA(1);
if ( ((LA10_0 >= ANY && LA10_0 <= COLON)||(LA10_0 >= COMMENT && LA10_0 <= IMPORT)||(LA10_0 >= LINE_COMMENT && LA10_0 <= RCURLY)||LA10_0==SPACE_CHAR||(LA10_0 >= STRING_CHAR && LA10_0 <= STRING_MACR)||(LA10_0 >= URI_CHAR && LA10_0 <= XML_COMMENT_OPEN)) ) {
alt10=1;
}
switch (alt10) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:108:12: q= media
{
pushFollow(FOLLOW_media_in_import_rule352);
q=media();
state._fsp--;
mediaQuery = q;
}
break;
}
match(input,SEMICOLON,FOLLOW_SEMICOLON_in_import_rule365);
}
if (matchingMedia(mediaQuery))
for (java.net.URI i : imports)
try {
java.net.URL url; {
try {
if (base != null)
i = org.daisy.common.file.URLs.resolve(base, i);
url = org.daisy.common.file.URLs.asURL(i);
} catch (RuntimeException e) {
throw new java.io.IOException(e);
}
}
vars.addAll(
analyzer.getVariableDeclarations(
new cz.vutbr.web.csskit.antlr.CSSSource(url,
java.nio.charset.StandardCharsets.UTF_8,
null)));
} catch (java.io.IOException e) {
logger.warn("Could not import stylesheet; skipping: " + i, e);
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return vars;
}
// $ANTLR end "import_rule"
// $ANTLR start "media_rule"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:133:1: media_rule returns [java.util.Collection vars] : ( MEDIA ( S )? q= media LCURLY v= variables RCURLY ) ;
public final java.util.Collection media_rule() throws RecognitionException {
java.util.Collection vars = null;
String q =null;
java.util.Collection v =null;
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:134:5: ( ( MEDIA ( S )? q= media LCURLY v= variables RCURLY ) )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:134:7: ( MEDIA ( S )? q= media LCURLY v= variables RCURLY )
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:134:7: ( MEDIA ( S )? q= media LCURLY v= variables RCURLY )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:134:8: MEDIA ( S )? q= media LCURLY v= variables RCURLY
{
match(input,MEDIA,FOLLOW_MEDIA_in_media_rule390);
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:134:14: ( S )?
int alt11=2;
int LA11_0 = input.LA(1);
if ( (LA11_0==S) ) {
alt11=1;
}
switch (alt11) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:134:14: S
{
match(input,S,FOLLOW_S_in_media_rule392);
}
break;
}
pushFollow(FOLLOW_media_in_media_rule397);
q=media();
state._fsp--;
match(input,LCURLY,FOLLOW_LCURLY_in_media_rule399);
pushFollow(FOLLOW_variables_in_media_rule403);
v=variables();
state._fsp--;
match(input,RCURLY,FOLLOW_RCURLY_in_media_rule405);
}
if (matchingMedia(q))
vars = v;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return vars;
}
// $ANTLR end "media_rule"
// $ANTLR start "media"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:140:1: media returns [String media] : t=~ ( S | LCURLY | SEMICOLON | COMMA | STRING | URI ) (t=~ ( LCURLY | SEMICOLON ) )* ;
public final String media() throws RecognitionException {
String media = null;
Token t=null;
StringBuilder s = new StringBuilder();
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:147:5: (t=~ ( S | LCURLY | SEMICOLON | COMMA | STRING | URI ) (t=~ ( LCURLY | SEMICOLON ) )* )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:147:7: t=~ ( S | LCURLY | SEMICOLON | COMMA | STRING | URI ) (t=~ ( LCURLY | SEMICOLON ) )*
{
t=input.LT(1);
if ( (input.LA(1) >= ANY && input.LA(1) <= COLON)||(input.LA(1) >= COMMENT && input.LA(1) <= IMPORT)||(input.LA(1) >= LINE_COMMENT && input.LA(1) <= RCURLY)||input.LA(1)==SPACE_CHAR||(input.LA(1) >= STRING_CHAR && input.LA(1) <= STRING_MACR)||(input.LA(1) >= URI_CHAR && input.LA(1) <= XML_COMMENT_OPEN) ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
s.append(t.getText());
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:148:7: (t=~ ( LCURLY | SEMICOLON ) )*
loop12:
while (true) {
int alt12=2;
int LA12_0 = input.LA(1);
if ( ((LA12_0 >= ANY && LA12_0 <= IMPORT)||(LA12_0 >= LINE_COMMENT && LA12_0 <= S)||(LA12_0 >= SPACE_CHAR && LA12_0 <= XML_COMMENT_OPEN)) ) {
alt12=1;
}
switch (alt12) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:148:8: t=~ ( LCURLY | SEMICOLON )
{
t=input.LT(1);
if ( (input.LA(1) >= ANY && input.LA(1) <= IMPORT)||(input.LA(1) >= LINE_COMMENT && input.LA(1) <= S)||(input.LA(1) >= SPACE_CHAR && input.LA(1) <= XML_COMMENT_OPEN) ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
s.append(t.getText());
}
break;
default :
break loop12;
}
}
}
media = s.toString().trim();
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return media;
}
// $ANTLR end "media"
// $ANTLR start "import_uri"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:151:1: import_uri returns [java.net.URI uri] : (s= STRING |u= URI ) ;
public final java.net.URI import_uri() throws RecognitionException {
java.net.URI uri = null;
Token s=null;
Token u=null;
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:152:5: ( (s= STRING |u= URI ) )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:152:7: (s= STRING |u= URI )
{
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:152:7: (s= STRING |u= URI )
int alt13=2;
int LA13_0 = input.LA(1);
if ( (LA13_0==STRING) ) {
alt13=1;
}
else if ( (LA13_0==URI) ) {
alt13=2;
}
else {
NoViableAltException nvae =
new NoViableAltException("", 13, 0, input);
throw nvae;
}
switch (alt13) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:152:9: s= STRING
{
s=(Token)match(input,STRING,FOLLOW_STRING_in_import_uri501);
String t = s.getText();
t = t.substring(1, t.length() - 1);
t = org.unbescape.css.CssEscape.unescapeCss(t);
uri = java.net.URI.create(t);
}
break;
case 2 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:158:9: u= URI
{
u=(Token)match(input,URI,FOLLOW_URI_in_import_uri515);
String t = u.getText();
t = t.substring(4, t.length() - 1);
t = t.trim();
if (t.length() > 0 && (t.charAt(0) == '\'' || t.charAt(0) == '"')) {
t = t.substring(1, t.length() - 1);
t = org.unbescape.css.CssEscape.unescapeCss(t);
}
uri = java.net.URI.create(t);
}
break;
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return uri;
}
// $ANTLR end "import_uri"
// $ANTLR start "rule_block"
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:171:1: rule_block : LCURLY ( rule_block |~ ( RCURLY | LCURLY ) )* RCURLY ;
public final void rule_block() throws RecognitionException {
try {
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:172:5: ( LCURLY ( rule_block |~ ( RCURLY | LCURLY ) )* RCURLY )
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:172:7: LCURLY ( rule_block |~ ( RCURLY | LCURLY ) )* RCURLY
{
match(input,LCURLY,FOLLOW_LCURLY_in_rule_block542);
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:173:10: ( rule_block |~ ( RCURLY | LCURLY ) )*
loop14:
while (true) {
int alt14=3;
int LA14_0 = input.LA(1);
if ( (LA14_0==LCURLY) ) {
alt14=1;
}
else if ( ((LA14_0 >= ANY && LA14_0 <= IMPORT)||(LA14_0 >= LINE_COMMENT && LA14_0 <= QUOT)||(LA14_0 >= S && LA14_0 <= XML_COMMENT_OPEN)) ) {
alt14=2;
}
switch (alt14) {
case 1 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:173:12: rule_block
{
pushFollow(FOLLOW_rule_block_in_rule_block555);
rule_block();
state._fsp--;
}
break;
case 2 :
// org/daisy/pipeline/css/sass/impl/SassDocumentation.g:174:12: ~ ( RCURLY | LCURLY )
{
if ( (input.LA(1) >= ANY && input.LA(1) <= IMPORT)||(input.LA(1) >= LINE_COMMENT && input.LA(1) <= QUOT)||(input.LA(1) >= S && input.LA(1) <= XML_COMMENT_OPEN) ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
break;
default :
break loop14;
}
}
match(input,RCURLY,FOLLOW_RCURLY_in_rule_block593);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
}
// $ANTLR end "rule_block"
// Delegated rules
public static final BitSet FOLLOW_variables_in_start44 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_comment_in_variables71 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_VAR_DECL_in_variables86 = new BitSet(new long[]{0x0000007FEFFFEFF0L});
public static final BitSet FOLLOW_variable_value_in_variables92 = new BitSet(new long[]{0x0000000010001000L});
public static final BitSet FOLLOW_DEFAULT_in_variables95 = new BitSet(new long[]{0x0000000018000000L});
public static final BitSet FOLLOW_S_in_variables99 = new BitSet(new long[]{0x0000000010000000L});
public static final BitSet FOLLOW_SEMICOLON_in_variables104 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_import_rule_in_variables126 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_media_rule_in_variables140 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_rule_block_in_variables152 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_set_in_variables164 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_S_in_variables191 = new BitSet(new long[]{0x0000007FFBFFFFF2L});
public static final BitSet FOLLOW_set_in_variable_value235 = new BitSet(new long[]{0x0000007FEFFFEFF2L});
public static final BitSet FOLLOW_COMMENT_in_comment268 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_IMPORT_in_import_rule297 = new BitSet(new long[]{0x0000000248000000L});
public static final BitSet FOLLOW_S_in_import_rule306 = new BitSet(new long[]{0x0000000240000000L});
public static final BitSet FOLLOW_import_uri_in_import_rule311 = new BitSet(new long[]{0x0000007DBFFBFFF0L});
public static final BitSet FOLLOW_S_in_import_rule323 = new BitSet(new long[]{0x0000000000000200L});
public static final BitSet FOLLOW_COMMA_in_import_rule326 = new BitSet(new long[]{0x0000000248000000L});
public static final BitSet FOLLOW_S_in_import_rule328 = new BitSet(new long[]{0x0000000240000000L});
public static final BitSet FOLLOW_import_uri_in_import_rule333 = new BitSet(new long[]{0x0000007DBFFBFFF0L});
public static final BitSet FOLLOW_S_in_import_rule346 = new BitSet(new long[]{0x0000007DB7FBFDF0L});
public static final BitSet FOLLOW_media_in_import_rule352 = new BitSet(new long[]{0x0000000010000000L});
public static final BitSet FOLLOW_SEMICOLON_in_import_rule365 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_MEDIA_in_media_rule390 = new BitSet(new long[]{0x0000007DAFFBFDF0L});
public static final BitSet FOLLOW_S_in_media_rule392 = new BitSet(new long[]{0x0000007DA7FBFDF0L});
public static final BitSet FOLLOW_media_in_media_rule397 = new BitSet(new long[]{0x0000000000040000L});
public static final BitSet FOLLOW_LCURLY_in_media_rule399 = new BitSet(new long[]{0x0000007FFFFFFFF0L});
public static final BitSet FOLLOW_variables_in_media_rule403 = new BitSet(new long[]{0x0000000004000000L});
public static final BitSet FOLLOW_RCURLY_in_media_rule405 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_set_in_media441 = new BitSet(new long[]{0x0000007FEFFBFFF2L});
public static final BitSet FOLLOW_set_in_media467 = new BitSet(new long[]{0x0000007FEFFBFFF2L});
public static final BitSet FOLLOW_STRING_in_import_uri501 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_URI_in_import_uri515 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_LCURLY_in_rule_block542 = new BitSet(new long[]{0x0000007FFFFFFFF0L});
public static final BitSet FOLLOW_rule_block_in_rule_block555 = new BitSet(new long[]{0x0000007FFFFFFFF0L});
public static final BitSet FOLLOW_set_in_rule_block568 = new BitSet(new long[]{0x0000007FFFFFFFF0L});
public static final BitSet FOLLOW_RCURLY_in_rule_block593 = new BitSet(new long[]{0x0000000000000002L});
}