private static CSSTreeParser feedAST(CommonTokenStream source, CommonTree ast, Preparator preparator, List<MediaQuery> media) { if (log.isTraceEnabled()) { log.trace("Feeding tree parser with AST:\n{}", TreeUtil.toStringTree(ast)); } // Walk resulting tree; create tree-node stream first CommonTreeNodeStream nodes = new CommonTreeNodeStream(ast); // AST nodes have payloads that point into token stream nodes.setTokenStream(source); CSSTreeParser parser = new CSSTreeParser(nodes); parser.init(preparator, media); return parser; }
logEnter("statement"); statement_stack.peek().invalid = false; pushFollow(FOLLOW_ruleset_in_statement177); rs=ruleset(); state._fsp--; pushFollow(FOLLOW_atstatement_in_statement187); ats=atstatement(); state._fsp--; match(input,INVALID_STATEMENT,FOLLOW_INVALID_STATEMENT_in_statement194); statement_stack.peek().invalid = true; debug("Statement is invalid"); logLeave("statement"); reportError(re); recover(input,re);
logEnter("selpart"); h=(CommonTree)match(input,HASH,FOLLOW_HASH_in_selpart2182); part = rf.createID(extractText(h)); c=(CommonTree)match(input,CLASSKEYWORD,FOLLOW_CLASSKEYWORD_in_selpart2194); part = rf.createClass(extractText(c)); match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_selpart2205); match(input, Token.DOWN, null); pushFollow(FOLLOW_attribute_in_selpart2209); ea=attribute(); state._fsp--; match(input, Token.UP, null); pushFollow(FOLLOW_pseudo_in_selpart2223); p=pseudo(); state._fsp--; match(input,INVALID_SELPART,FOLLOW_INVALID_SELPART_in_selpart2233); logLeave("selpart"); reportError(re); recover(input,re);
public final String namespace_prefix() throws RecognitionException { String prf = null; CommonTree i=null; try { // CSSTreeParser.g:357:3: ( (i= IDENT ) ) // CSSTreeParser.g:357:5: (i= IDENT ) { // CSSTreeParser.g:357:5: (i= IDENT ) // CSSTreeParser.g:357:6: i= IDENT { i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_namespace_prefix623); } prf = extractText(i); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return prf; } // $ANTLR end "namespace_prefix"
public final RuleMargin margin() throws RecognitionException { RuleMargin m = null; CommonTree area=null; List<Declaration> decl =null; logEnter("margin"); try { // cz/vutbr/web/csskit/antlr/CSSTreeParser.g:254:2: ( ^(area= MARGIN_AREA decl= declarations ) ) // cz/vutbr/web/csskit/antlr/CSSTreeParser.g:254:4: ^(area= MARGIN_AREA decl= declarations ) { area=(CommonTree)match(input,MARGIN_AREA,FOLLOW_MARGIN_AREA_in_margin498); match(input, Token.DOWN, null); pushFollow(FOLLOW_declarations_in_margin504); decl=declarations(); state._fsp--; match(input, Token.UP, null); m = preparator.prepareRuleMargin(extractText(area).substring(1), decl); } logLeave("margin"); } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return m; } // $ANTLR end "margin"
logEnter("inlineset"); List<cz.vutbr.web.css.Selector.PseudoPage> pplist = new ArrayList<cz.vutbr.web.css.Selector.PseudoPage>(); match(input,RULE,FOLLOW_RULE_in_inlineset887); match(input, Token.DOWN, null); pushFollow(FOLLOW_pseudo_in_inlineset892); p=pseudo(); state._fsp--; pushFollow(FOLLOW_declarations_in_inlineset900); decl=declarations(); state._fsp--; match(input, Token.UP, null); logLeave("inlineset"); reportError(re); recover(input,re);
logEnter("atstatement"); statement_stack.peek().insideAtstatement =true; atstatement_stack.peek().stm = stmnt = null; match(input,CHARSET,FOLLOW_CHARSET_in_atstatement227); match(input,INVALID_IMPORT,FOLLOW_INVALID_IMPORT_in_atstatement233); match(input,IMPORT,FOLLOW_IMPORT_in_atstatement240); match(input, Token.DOWN, null); pushFollow(FOLLOW_media_in_atstatement252); im=media(); state._fsp--; pushFollow(FOLLOW_import_uri_in_atstatement266); iuri=import_uri(); state._fsp--; match(input, Token.UP, null); debug("Adding import: {}", iuri); importMedia.add(im); importPaths.add(iuri); debug("Ignoring import: {}", iuri); n=(CommonTree)match(input,NAMESPACE,FOLLOW_NAMESPACE_in_atstatement286); match(input, Token.DOWN, null);
logEnter("ruleset"); List<cz.vutbr.web.css.CombinedSelector> cslist = new ArrayList<cz.vutbr.web.css.CombinedSelector>(); match(input,RULE,FOLLOW_RULE_in_ruleset953); match(input, Token.DOWN, null); pushFollow(FOLLOW_combined_selector_in_ruleset967); cs=combined_selector(); state._fsp--; debug("Inserted combined selector ({}) into ruleset", cslist.size()); pushFollow(FOLLOW_declarations_in_ruleset988); decl=declarations(); state._fsp--; match(input, Token.UP, null); debug("Ruleset not valid, so not created"); this.preventImports = true; logLeave("ruleset"); reportError(re); recover(input,re);
logEnter("atstatement"); ((statement_scope)statement_stack.peek()).insideAtstatement =true; ((atstatement_scope)atstatement_stack.peek()).stm = stmnt = null; match(input,CHARSET,FOLLOW_CHARSET_in_atstatement233); match(input,INVALID_IMPORT,FOLLOW_INVALID_IMPORT_in_atstatement239); i=(CommonTree)match(input,IMPORT,FOLLOW_IMPORT_in_atstatement247); String media = extractText(i); imports.push(new TreeParserState(media)); match(input,IMPORT_END,FOLLOW_IMPORT_END_in_atstatement258); match(input,PAGE,FOLLOW_PAGE_in_atstatement267); match(input, Token.DOWN, null); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_atstatement278); name = extractText(i); match(input,PSEUDO,FOLLOW_PSEUDO_in_atstatement307); match(input, Token.DOWN, null); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_atstatement311); match(input, Token.UP, null);
match(input,MINUS,FOLLOW_MINUS_in_valuepart1029); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_valuepart1037); ((terms_scope)terms_stack.peek()).term = tf.createIdent(extractText(i), ((terms_scope)terms_stack.peek()).dash); match(input,CLASSKEYWORD,FOLLOW_CLASSKEYWORD_in_valuepart1049); match(input,MINUS,FOLLOW_MINUS_in_valuepart1059); n=(CommonTree)match(input,NUMBER,FOLLOW_NUMBER_in_valuepart1067); ((terms_scope)terms_stack.peek()).term = tf.createNumeric(extractText(n), ((terms_scope)terms_stack.peek()).unary); match(input,MINUS,FOLLOW_MINUS_in_valuepart1081); p=(CommonTree)match(input,PERCENTAGE,FOLLOW_PERCENTAGE_in_valuepart1089); ((terms_scope)terms_stack.peek()).term = tf.createPercent(extractText(p), ((terms_scope)terms_stack.peek()).unary); match(input,MINUS,FOLLOW_MINUS_in_valuepart1101); d=(CommonTree)match(input,DIMENSION,FOLLOW_DIMENSION_in_valuepart1109); String dim = extractText(d); ((terms_scope)terms_stack.peek()).term = tf.createDimension(dim, ((terms_scope)terms_stack.peek()).unary); if(((terms_scope)terms_stack.peek()).term==null) { pushFollow(FOLLOW_string_in_valuepart1127);
logEnter("declarations"); decl = new ArrayList<cz.vutbr.web.css.Declaration>(); match(input,SET,FOLLOW_SET_in_declarations1029); if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); pushFollow(FOLLOW_declaration_in_declarations1034); d=declaration(); state._fsp--; debug("Inserted declaration #{} ", decl.size()+1); match(input, Token.UP, null); logLeave("declarations"); reportError(re); recover(input,re);
logEnter("attribute"); String attribute = null; String value = null; i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_attribute1784); attribute=extractText(i); match(input,EQUALS,FOLLOW_EQUALS_in_attribute1793); match(input,INCLUDES,FOLLOW_INCLUDES_in_attribute1804); match(input,DASHMATCH,FOLLOW_DASHMATCH_in_attribute1815); match(input,CONTAINS,FOLLOW_CONTAINS_in_attribute1826); match(input,STARTSWITH,FOLLOW_STARTSWITH_in_attribute1837); match(input,ENDSWITH,FOLLOW_ENDSWITH_in_attribute1848); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_attribute1866); value=extractText(i); isStringValue=false; pushFollow(FOLLOW_string_in_attribute1878); s=string(); logLeave("attribute");
logEnter("selector"); sel = (cz.vutbr.web.css.Selector)rf.createSelector().unlock(); String name = null; match(input,SELECTOR,FOLLOW_SELECTOR_in_selector1857); match(input, Token.DOWN, null); match(input,ELEMENT,FOLLOW_ELEMENT_in_selector1868); match(input, Token.DOWN, null); match(input,PREFIX,FOLLOW_PREFIX_in_selector1896); if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); pushFollow(FOLLOW_namespace_prefix_in_selector1917); p=namespace_prefix(); state._fsp--; match(input,ASTERISK,FOLLOW_ASTERISK_in_selector1953); prf = cz.vutbr.web.css.Selector.ElementName.WILDCARD; match(input, Token.UP, null); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_selector2018); name = extractText(i); match(input,ASTERISK,FOLLOW_ASTERISK_in_selector2050); name = cz.vutbr.web.css.Selector.ElementName.WILDCARD; match(input, Token.UP, null);
logEnter("combined_selector"); combinedSelector = (cz.vutbr.web.css.CombinedSelector) rf.createCombinedSelector().unlock(); boolean invalid = false; pushFollow(FOLLOW_selector_in_combined_selector1756); s=selector(); state._fsp--; pushFollow(FOLLOW_combinator_in_combined_selector1765); c=combinator(); state._fsp--; pushFollow(FOLLOW_selector_in_combined_selector1769); s=selector(); state._fsp--; combinedSelector = null; if(statement_stack.peek().invalid) { debug("Ommiting combined selector, whole statement discarded"); debug("Combined selector is invalid"); debug("Returing combined selector: {}.", combinedSelector); logLeave("combined_selector"); reportError(re); recover(input,re);
logEnter("selector"); ((selector_scope)selector_stack.peek()).s =sel=(Selector)rf.createSelector().unlock(); Selector.ElementName en = rf.createElement(Selector.ElementName.WILDCARD); match(input,SELECTOR,FOLLOW_SELECTOR_in_selector1547); match(input, Token.DOWN, null); match(input,ELEMENT,FOLLOW_ELEMENT_in_selector1559); match(input, Token.DOWN, null); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_selector1575); en.setName(extractText(i)); match(input, Token.UP, null); pushFollow(FOLLOW_selpart_in_selector1622); selpart(); match(input, Token.UP, null); match(input,SELECTOR,FOLLOW_SELECTOR_in_selector1641); match(input, Token.DOWN, null); pushFollow(FOLLOW_selpart_in_selector1653); selpart();
logEnter("property"); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_property1200); declaration_stack.peek().d.setProperty(extractText(i)); declaration_stack.peek().d.setSource(extractSource(i)); match(input,MINUS,FOLLOW_MINUS_in_property1208); i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_property1214); declaration_stack.peek().d.setProperty("-" + extractText(i)); declaration_stack.peek().d.setSource(extractSource(i)); debug("Setting property: {}", declaration_stack.peek().d.getProperty()); logLeave("property"); reportError(re); recover(input,re);
match(input,IDENT,FOLLOW_IDENT_in_any2676); match(input,CLASSKEYWORD,FOLLOW_CLASSKEYWORD_in_any2682); match(input,NUMBER,FOLLOW_NUMBER_in_any2688); match(input,PERCENTAGE,FOLLOW_PERCENTAGE_in_any2694); match(input,DIMENSION,FOLLOW_DIMENSION_in_any2700); pushFollow(FOLLOW_string_in_any2706); string(); state._fsp--; match(input,URI,FOLLOW_URI_in_any2712); match(input,HASH,FOLLOW_HASH_in_any2718); match(input,UNIRANGE,FOLLOW_UNIRANGE_in_any2724); match(input,INCLUDES,FOLLOW_INCLUDES_in_any2730); match(input,COLON,FOLLOW_COLON_in_any2736); match(input,COMMA,FOLLOW_COMMA_in_any2742); match(input,GREATER,FOLLOW_GREATER_in_any2748); match(input,EQUALS,FOLLOW_EQUALS_in_any2754);
i=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_mediaterm790); String m = extractText(i); MediaQueryState state = mediaquery_stack.peek().state; if (m.equalsIgnoreCase("ONLY") && state == MediaQueryState.START) trace("Invalid media query: found ident: {} state: {}", m, state); mediaquery_stack.peek().invalid = true; pushFollow(FOLLOW_mediaexpression_in_mediaterm810); e=mediaexpression(); state._fsp--; trace("Invalidating media query for invalud expression"); mediaquery_stack.peek().invalid = true; trace("Invalid media query: found expr, state: {}", mediaquery_stack.peek().state); mediaquery_stack.peek().invalid = true; match(input,INVALID_STATEMENT,FOLLOW_INVALID_STATEMENT_in_mediaterm821); reportError(re); recover(input,re);
logEnter("ruleset"); List<CombinedSelector> cslist = new ArrayList<CombinedSelector>(); match(input,RULE,FOLLOW_RULE_in_ruleset639); match(input, Token.DOWN, null); pushFollow(FOLLOW_combined_selector_in_ruleset653); cs=combined_selector(); pushFollow(FOLLOW_declarations_in_ruleset674); decl=declarations(); match(input, Token.UP, null); imports.isEmpty() ? null : imports.peek().media); logLeave("ruleset"); reportError(re); recover(input,re);
uri=(CommonTree)match(input,URI,FOLLOW_URI_in_namespace_uri646); s = extractText(uri); str=(CommonTree)match(input,STRING,FOLLOW_STRING_in_namespace_uri658); s = extractTextUnescaped(str); reportError(re); recover(input,re);