com.vaadin.sass.internal.parser
Class Parser

java.lang.Object
  extended by com.vaadin.sass.internal.parser.Parser
All Implemented Interfaces:
ParserConstants, org.w3c.css.sac.Parser

public class Parser
extends Object
implements org.w3c.css.sac.Parser, ParserConstants

A CSS2 parser

Version:
$Revision: 1.15 $
Author:
Philippe Le H�garet

Field Summary
protected  org.w3c.css.sac.ConditionFactory conditionFactory
           
protected  SCSSDocumentHandlerImpl documentHandler
           
protected  org.w3c.css.sac.ErrorHandler errorHandler
           
 Token jj_nt
          Next token.
protected  org.w3c.css.sac.SelectorFactory selectorFactory
           
protected  org.w3c.css.sac.InputSource source
           
 Token token
          Current token.
 ParserTokenManager token_source
          Generated Token Manager.
 
Fields inherited from interface com.vaadin.sass.internal.parser.ParserConstants
_URL, AND, ANY, ATKEYWORD, CDC, CDO, CHARSET_SYM, CM, COLON, COMMA, COMPARE, CONTENT_SYM, D, DASHMATCH, DEBUG_SYM, DEFAULT, DEG, DIMEN, DIV, DOT, EACH_IN, EACH_SYM, ELLIPSIS, ELSE_SYM, EMS, EOF, EQ, ESCAPE, EXS, EXTEND_SYM, FONT_FACE_SYM, FOR_SYM, FORMAL_COMMENT, FROM, FUNCTION, FUNCTION_SYM, GRAD, GTE, GUARDED_SYM, H, HASH, HZ, IDENT, IF, IF_SYM, IMPORT_SYM, IMPORTANT_SYM, IN, IN_FORMAL_COMMENT, IN_MULTI_LINE_COMMENT, INCLUDE_SYM, INCLUDES, INTERPOLATION, KEY_FRAME_SYM, KHZ, LBRACE, LBRACKET, LEM, LPARAN, LTE, MEDIA_SYM, MICROSOFT_RULE, MINUS, MIXIN_SYM, MM, MOD, MOZ_DOCUMENT_SYM, MS, MULTI_LINE_COMMENT, NAME, NMCHAR, NMSTART, NONASCII, NOT, NOT_EQ, NUMBER, OR, PAGE_SYM, PARENT, PC, PERCENTAGE, PLUS, PRECEDES, PREFIXMATCH, PT, PX, RAD, RANGE, RANGE0, RANGE1, RANGE2, RANGE3, RANGE4, RANGE5, RANGE6, RBRACE, RBRACKET, REM, RETURN_SYM, RPARAN, S, SECOND, SEMICOLON, SIBLING, SINGLE_LINE_COMMENT, STRING, STRINGCHAR, SUBSTRINGMATCH, SUCCEEDS, SUFFIXMATCH, SUPPORTS_SYM, THROUGH, TO, tokenImage, UNI, UNICODE, UNICODERANGE, UNKNOWN, URL, VARIABLE, WARN_SYM, WHILE_SYM
 
Constructor Summary
Parser()
          Creates a new Parser
Parser(CharStream stream)
          Constructor with user supplied CharStream.
Parser(ParserTokenManager tm)
          Constructor with generated Token Manager.
 
Method Summary
 void _parseDeclarationBlock()
           
 void _parseImportRule()
           
 void _parseMediaRule()
           
 void _parseRule()
          The following functions are useful for a DOM CSS implementation only and are not part of the general CSS2 parser.
 List<Selector> _parseSelectors()
           
 void addExpressionTerm(List<SassListItem> items)
           
 ArrayList<VariableNode> arglist()
           
 ArrayList<VariableNode> argValuelist()
           
 VariableNode argValueListItem()
           
 List<SassListItem> arithmeticOrBooleanOperator()
           
 void atRuleDeclaration()
           
 AttributeSelector attribute_selector()
           
 List<SassListItem> booleanOperator()
           
 void charset()
           
 SimpleSelector class_selector()
           
 Combinator combinator()
           
 Combinator combinatorChar()
          to refactor combinator and reuse in selector().
 void contentDirective()
           
 void controlDirective()
           
 void debugDirective()
           
 void debuggingDirective()
           
 void declaration()
           
 void declarationOrNestedProperties()
           
 void disable_tracing()
          Disable tracing.
 void eachDirective()
           
 void elseDirective()
           
 void enable_tracing()
          Enable tracing.
 SassListItem expr()
           
 SassList expressionList()
           
 SassList expressionSubList()
           
 void extendDirective()
           
 void fontFace()
           
 void forDirective()
           
 LexicalUnitImpl function(char operator)
          Handle all CSS2 functions.
 void functionBlockStatement()
           
 void functionControlDirective()
           
 void functionDirective()
           
 void functionEachDirective()
           
 void functionElseDirective()
           
 void functionForDirective()
           
 void functionIfDirective()
           
 String functionName()
           
 ParseException generateParseException()
          Generate ParseException.
 org.w3c.css.sac.InputSource getInputSource()
           
 Token getNextToken()
          Get the next Token.
 String getParserVersion()
          This methods returns "http://www.w3.org/TR/REC-CSS2".
 Token getToken(int index)
          Get the specific Token.
 boolean guarded()
           
 LexicalUnitImpl hexcolor()
           
 IdSelector id_selector()
           
 String ident_interpolation_seq()
           
 Token ident()
           
 String identInterpolationString()
           
 void ifContentStatement()
           
 void ifDirective()
           
 void ignoreStatement()
           
 void importDeclaration()
          The import statement
 void includeDirective()
           
 void includeDirectiveBlockContents()
           
 String interpolation()
           
 void keyframes()
           
 void keyframeSelector()
           
 void media()
           
 void mediaDirective()
           
 void mediaStatement(MediaListImpl ml)
           
 String medium()
           
 void microsoftExtension()
           
 VariableNode mixinArg()
           
 void mixinDirective()
           
 void nestedProperties()
           
 List<SassListItem> nonCommaOperator()
           
 List<SassListItem> nonVariableTerm()
           
 List<SassListItem> numberTerm(char op)
           
 SassListItem numericExpr()
           
 List<SassListItem> numericTerm()
           
 List<SassListItem> operator()
           
 void page()
           
 SassListItem parenthesizedExpression()
           
 void parseImportRule(org.w3c.css.sac.InputSource source)
          Parse methods used by DOM Level 2 implementation.
 void parseMediaRule(org.w3c.css.sac.InputSource source)
           
 boolean parsePriority(org.w3c.css.sac.InputSource source)
           
 org.w3c.css.sac.LexicalUnit parsePropertyValue(org.w3c.css.sac.InputSource source)
           
 void parseRule(org.w3c.css.sac.InputSource source)
          This method parses only one rule (style rule or at-rule, except @charset).
 void parserUnit()
          The main entry for the parser.
 List<Selector> parseSCSSSelectors(org.w3c.css.sac.InputSource source)
           
 org.w3c.css.sac.SelectorList parseSelectors(org.w3c.css.sac.InputSource source)
           
 void parseStyleDeclaration(org.w3c.css.sac.InputSource source)
          This method parses a style declaration (including the surrounding curly braces).
 void parseStyleSheet(org.w3c.css.sac.InputSource source)
          Main parse methods
 void parseStyleSheet(String systemId)
          Convenient method for URIs.
 SimpleSelector placeholder_selector()
           
 boolean prio()
           
 String property()
           
 Token propertyIdent()
           
 String pseudo_page()
           
 SimpleSelector pseudo_selector()
           
 void ReInit(CharStream stream)
          Reinitialise.
 void ReInit(ParserTokenManager tm)
          Reinitialise.
 void returnDirective()
           
 Selector selector()
           
 List<Selector> selectorList()
           
 void semicolonTerminator()
           
 void setConditionFactory(org.w3c.css.sac.ConditionFactory conditionFactory)
           
 void setDocumentHandler(org.w3c.css.sac.DocumentHandler handler)
          Set the document handler for this parser
 void setErrorHandler(org.w3c.css.sac.ErrorHandler error)
          Set the error handler for this parser
 void setLocale(Locale locale)
           
 void setSelectorFactory(org.w3c.css.sac.SelectorFactory selectorFactory)
           
 SimpleSelector simple_nontype_selector()
           
 SimpleSelectorSequence simple_selector_sequence()
           
 void skipUnknownRule()
           
 List<SassListItem> stringTerm(char op)
           
 void styleRule()
           
 void styleRuleOrDeclarationOrNestedProperties()
           
 List<SassListItem> term()
           
 void topLevelDeclaration()
           
 TypeSelector type_selector()
           
 char unaryOperator()
           
 LexicalUnitImpl unicode()
           
 LexicalUnitImpl url()
           
 void variable()
           
 String variableName()
           
 List<SassListItem> variableTerm()
           
 void warnDirective()
           
 void whileDirective()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

documentHandler

protected SCSSDocumentHandlerImpl documentHandler

errorHandler

protected org.w3c.css.sac.ErrorHandler errorHandler

source

protected org.w3c.css.sac.InputSource source

conditionFactory

protected org.w3c.css.sac.ConditionFactory conditionFactory

selectorFactory

protected org.w3c.css.sac.SelectorFactory selectorFactory

token_source

public ParserTokenManager token_source
Generated Token Manager.


token

public Token token
Current token.


jj_nt

public Token jj_nt
Next token.

Constructor Detail

Parser

public Parser()
Creates a new Parser


Parser

public Parser(CharStream stream)
Constructor with user supplied CharStream.


Parser

public Parser(ParserTokenManager tm)
Constructor with generated Token Manager.

Method Detail

setLocale

public void setLocale(Locale locale)
               throws org.w3c.css.sac.CSSException
Specified by:
setLocale in interface org.w3c.css.sac.Parser
Throws:
org.w3c.css.sac.CSSException - Not yet implemented

getInputSource

public org.w3c.css.sac.InputSource getInputSource()

setDocumentHandler

public void setDocumentHandler(org.w3c.css.sac.DocumentHandler handler)
Set the document handler for this parser

Specified by:
setDocumentHandler in interface org.w3c.css.sac.Parser

setSelectorFactory

public void setSelectorFactory(org.w3c.css.sac.SelectorFactory selectorFactory)
Specified by:
setSelectorFactory in interface org.w3c.css.sac.Parser

setConditionFactory

public void setConditionFactory(org.w3c.css.sac.ConditionFactory conditionFactory)
Specified by:
setConditionFactory in interface org.w3c.css.sac.Parser

setErrorHandler

public void setErrorHandler(org.w3c.css.sac.ErrorHandler error)
Set the error handler for this parser

Specified by:
setErrorHandler in interface org.w3c.css.sac.Parser

parseStyleSheet

public void parseStyleSheet(org.w3c.css.sac.InputSource source)
                     throws org.w3c.css.sac.CSSException,
                            IOException
Main parse methods

Specified by:
parseStyleSheet in interface org.w3c.css.sac.Parser
Parameters:
source - the source of the style sheet.
Throws:
IOException - the source can't be parsed.
org.w3c.css.sac.CSSException - the source is not CSS valid.

parseStyleSheet

public void parseStyleSheet(String systemId)
                     throws org.w3c.css.sac.CSSException,
                            IOException
Convenient method for URIs.

Specified by:
parseStyleSheet in interface org.w3c.css.sac.Parser
Parameters:
systemId - the fully resolved URI of the style sheet.
Throws:
IOException - the source can't be parsed.
org.w3c.css.sac.CSSException - the source is not CSS valid.

parseRule

public void parseRule(org.w3c.css.sac.InputSource source)
               throws org.w3c.css.sac.CSSException,
                      IOException
This method parses only one rule (style rule or at-rule, except @charset).

Specified by:
parseRule in interface org.w3c.css.sac.Parser
Parameters:
source - the source of the rule.
Throws:
IOException - the source can't be parsed.
org.w3c.css.sac.CSSException - the source is not CSS valid.

parseStyleDeclaration

public void parseStyleDeclaration(org.w3c.css.sac.InputSource source)
                           throws org.w3c.css.sac.CSSException,
                                  IOException
This method parses a style declaration (including the surrounding curly braces).

Specified by:
parseStyleDeclaration in interface org.w3c.css.sac.Parser
Parameters:
source - the source of the style declaration.
Throws:
IOException - the source can't be parsed.
org.w3c.css.sac.CSSException - the source is not CSS valid.

getParserVersion

public String getParserVersion()
This methods returns "http://www.w3.org/TR/REC-CSS2".

Specified by:
getParserVersion in interface org.w3c.css.sac.Parser
Returns:
the string "http://www.w3.org/TR/REC-CSS2".

parseImportRule

public void parseImportRule(org.w3c.css.sac.InputSource source)
                     throws org.w3c.css.sac.CSSException,
                            IOException
Parse methods used by DOM Level 2 implementation.

Throws:
org.w3c.css.sac.CSSException
IOException

parseMediaRule

public void parseMediaRule(org.w3c.css.sac.InputSource source)
                    throws org.w3c.css.sac.CSSException,
                           IOException
Throws:
org.w3c.css.sac.CSSException
IOException

parseSelectors

public org.w3c.css.sac.SelectorList parseSelectors(org.w3c.css.sac.InputSource source)
                                            throws org.w3c.css.sac.CSSException,
                                                   IOException
Specified by:
parseSelectors in interface org.w3c.css.sac.Parser
Throws:
org.w3c.css.sac.CSSException
IOException

parseSCSSSelectors

public List<Selector> parseSCSSSelectors(org.w3c.css.sac.InputSource source)
                                  throws org.w3c.css.sac.CSSException,
                                         IOException
Throws:
org.w3c.css.sac.CSSException
IOException

parsePropertyValue

public org.w3c.css.sac.LexicalUnit parsePropertyValue(org.w3c.css.sac.InputSource source)
                                               throws org.w3c.css.sac.CSSException,
                                                      IOException
Specified by:
parsePropertyValue in interface org.w3c.css.sac.Parser
Throws:
org.w3c.css.sac.CSSException
IOException

parsePriority

public boolean parsePriority(org.w3c.css.sac.InputSource source)
                      throws org.w3c.css.sac.CSSException,
                             IOException
Specified by:
parsePriority in interface org.w3c.css.sac.Parser
Throws:
org.w3c.css.sac.CSSException
IOException

parserUnit

public final void parserUnit()
                      throws ParseException
The main entry for the parser.

Throws:
ParseException - exception during the parse

charset

public final void charset()
                   throws ParseException
Throws:
ParseException

topLevelDeclaration

public final void topLevelDeclaration()
                               throws ParseException
Throws:
ParseException

ignoreStatement

public final void ignoreStatement()
                           throws ParseException
Throws:
ParseException

importDeclaration

public final void importDeclaration()
                             throws ParseException
The import statement

Throws:
ParseException - exception during the parse

keyframes

public final void keyframes()
                     throws ParseException
Throws:
ParseException - exception during the parse

keyframeSelector

public final void keyframeSelector()
                            throws ParseException
Throws:
ParseException

media

public final void media()
                 throws ParseException
Throws:
ParseException - exception during the parse

mediaDirective

public final void mediaDirective()
                          throws ParseException
Throws:
ParseException

mediaStatement

public final void mediaStatement(MediaListImpl ml)
                          throws ParseException
Throws:
ParseException

medium

public final String medium()
                    throws ParseException
Throws:
ParseException - exception during the parse

page

public final void page()
                throws ParseException
Throws:
ParseException - exception during the parse

pseudo_page

public final String pseudo_page()
                         throws ParseException
Throws:
ParseException

fontFace

public final void fontFace()
                    throws ParseException
Throws:
ParseException

atRuleDeclaration

public final void atRuleDeclaration()
                             throws ParseException
Throws:
ParseException - exception during the parse

skipUnknownRule

public final void skipUnknownRule()
                           throws ParseException
Throws:
ParseException

combinator

public final Combinator combinator()
                            throws ParseException
Throws:
ParseException - exception during the parse

combinatorChar

public final Combinator combinatorChar()
                                throws ParseException
to refactor combinator and reuse in selector().

Throws:
ParseException

microsoftExtension

public final void microsoftExtension()
                              throws ParseException
Throws:
ParseException

property

public final String property()
                      throws ParseException
Throws:
ParseException - exception during the parse

propertyIdent

public final Token propertyIdent()
                          throws ParseException
Throws:
ParseException

variableName

public final String variableName()
                          throws ParseException
Throws:
ParseException

functionName

public final String functionName()
                          throws ParseException
Throws:
ParseException

styleRule

public final void styleRule()
                     throws ParseException
Throws:
ParseException - exception during the parse

selectorList

public final List<Selector> selectorList()
                                  throws ParseException
Throws:
ParseException

selector

public final Selector selector()
                        throws ParseException
Throws:
ParseException

simple_selector_sequence

public final SimpleSelectorSequence simple_selector_sequence()
                                                      throws ParseException
Throws:
ParseException

simple_nontype_selector

public final SimpleSelector simple_nontype_selector()
                                             throws ParseException
Throws:
ParseException

ident_interpolation_seq

public final String ident_interpolation_seq()
                                     throws ParseException
Throws:
ParseException

class_selector

public final SimpleSelector class_selector()
                                    throws ParseException
Throws:
ParseException

placeholder_selector

public final SimpleSelector placeholder_selector()
                                          throws ParseException
Throws:
ParseException

type_selector

public final TypeSelector type_selector()
                                 throws ParseException
Throws:
ParseException

attribute_selector

public final AttributeSelector attribute_selector()
                                           throws ParseException
Throws:
ParseException - exception during the parse

pseudo_selector

public final SimpleSelector pseudo_selector()
                                     throws ParseException
Throws:
ParseException

id_selector

public final IdSelector id_selector()
                             throws ParseException
Throws:
ParseException

variable

public final void variable()
                    throws ParseException
Throws:
ParseException

expressionList

public final SassList expressionList()
                              throws ParseException
Throws:
ParseException

expressionSubList

public final SassList expressionSubList()
                                 throws ParseException
Throws:
ParseException

controlDirective

public final void controlDirective()
                            throws ParseException
Throws:
ParseException

ifContentStatement

public final void ifContentStatement()
                              throws ParseException
Throws:
ParseException

ifDirective

public final void ifDirective()
                       throws ParseException
Throws:
ParseException

elseDirective

public final void elseDirective()
                         throws ParseException
Throws:
ParseException

eachDirective

public final void eachDirective()
                         throws ParseException
Throws:
ParseException

mixinDirective

public final void mixinDirective()
                          throws ParseException
Throws:
ParseException

functionDirective

public final void functionDirective()
                             throws ParseException
Throws:
ParseException

functionBlockStatement

public final void functionBlockStatement()
                                  throws ParseException
Throws:
ParseException

functionControlDirective

public final void functionControlDirective()
                                    throws ParseException
Throws:
ParseException

functionIfDirective

public final void functionIfDirective()
                               throws ParseException
Throws:
ParseException

functionElseDirective

public final void functionElseDirective()
                                 throws ParseException
Throws:
ParseException

functionEachDirective

public final void functionEachDirective()
                                 throws ParseException
Throws:
ParseException

functionForDirective

public final void functionForDirective()
                                throws ParseException
Throws:
ParseException

arglist

public final ArrayList<VariableNode> arglist()
                                      throws ParseException
Throws:
ParseException

mixinArg

public final VariableNode mixinArg()
                            throws ParseException
Throws:
ParseException

argValuelist

public final ArrayList<VariableNode> argValuelist()
                                           throws ParseException
Throws:
ParseException

argValueListItem

public final VariableNode argValueListItem()
                                    throws ParseException
Throws:
ParseException

returnDirective

public final void returnDirective()
                           throws ParseException
Throws:
ParseException

includeDirective

public final void includeDirective()
                            throws ParseException
Throws:
ParseException

semicolonTerminator

public final void semicolonTerminator()
                               throws ParseException
Throws:
ParseException

includeDirectiveBlockContents

public final void includeDirectiveBlockContents()
                                         throws ParseException
Throws:
ParseException

interpolation

public final String interpolation()
                           throws ParseException
Throws:
ParseException

debuggingDirective

public final void debuggingDirective()
                              throws ParseException
Throws:
ParseException

debugDirective

public final void debugDirective()
                          throws ParseException
Throws:
ParseException

warnDirective

public final void warnDirective()
                         throws ParseException
Throws:
ParseException

forDirective

public final void forDirective()
                        throws ParseException
Throws:
ParseException

whileDirective

public final void whileDirective()
                          throws ParseException
Throws:
ParseException

extendDirective

public final void extendDirective()
                           throws ParseException
Throws:
ParseException

contentDirective

public final void contentDirective()
                            throws ParseException
Throws:
ParseException

nestedProperties

public final void nestedProperties()
                            throws ParseException
Throws:
ParseException

styleRuleOrDeclarationOrNestedProperties

public final void styleRuleOrDeclarationOrNestedProperties()
                                                    throws ParseException
Throws:
ParseException - exception during the parse

declarationOrNestedProperties

public final void declarationOrNestedProperties()
                                         throws ParseException
Throws:
ParseException - exception during the parse

declaration

public final void declaration()
                       throws ParseException
Throws:
ParseException - exception during the parse

prio

public final boolean prio()
                   throws ParseException
Throws:
ParseException - exception during the parse

guarded

public final boolean guarded()
                      throws ParseException
Throws:
ParseException

operator

public final List<SassListItem> operator()
                                  throws ParseException
Throws:
ParseException - exception during the parse

expr

public final SassListItem expr()
                        throws ParseException
Throws:
ParseException

addExpressionTerm

public final void addExpressionTerm(List<SassListItem> items)
                             throws ParseException
Throws:
ParseException

parenthesizedExpression

public final SassListItem parenthesizedExpression()
                                           throws ParseException
Throws:
ParseException

arithmeticOrBooleanOperator

public final List<SassListItem> arithmeticOrBooleanOperator()
                                                     throws ParseException
Throws:
ParseException - exception during the parse

booleanOperator

public final List<SassListItem> booleanOperator()
                                         throws ParseException
Throws:
ParseException

nonCommaOperator

public final List<SassListItem> nonCommaOperator()
                                          throws ParseException
Throws:
ParseException - exception during the parse

numericExpr

public final SassListItem numericExpr()
                               throws ParseException
Throws:
ParseException - exception during the parse

unaryOperator

public final char unaryOperator()
                         throws ParseException
Throws:
ParseException - exception during the parse

term

public final List<SassListItem> term()
                              throws ParseException
Throws:
ParseException - exception during the parse

numericTerm

public final List<SassListItem> numericTerm()
                                     throws ParseException
Throws:
ParseException - exception during the parse

variableTerm

public final List<SassListItem> variableTerm()
                                      throws ParseException
Throws:
ParseException

nonVariableTerm

public final List<SassListItem> nonVariableTerm()
                                         throws ParseException
Throws:
ParseException

numberTerm

public final List<SassListItem> numberTerm(char op)
                                    throws ParseException
Throws:
ParseException

identInterpolationString

public final String identInterpolationString()
                                      throws ParseException
Throws:
ParseException

ident

public final Token ident()
                  throws ParseException
Throws:
ParseException

stringTerm

public final List<SassListItem> stringTerm(char op)
                                    throws ParseException
Throws:
ParseException

function

public final LexicalUnitImpl function(char operator)
                               throws ParseException
Handle all CSS2 functions.

Throws:
ParseException - exception during the parse

unicode

public final LexicalUnitImpl unicode()
                              throws ParseException
Throws:
ParseException

url

public final LexicalUnitImpl url()
                          throws ParseException
Throws:
ParseException

hexcolor

public final LexicalUnitImpl hexcolor()
                               throws ParseException
Throws:
ParseException - exception during the parse

_parseRule

public final void _parseRule()
                      throws ParseException
The following functions are useful for a DOM CSS implementation only and are not part of the general CSS2 parser.

Throws:
ParseException

_parseImportRule

public final void _parseImportRule()
                            throws ParseException
Throws:
ParseException

_parseMediaRule

public final void _parseMediaRule()
                           throws ParseException
Throws:
ParseException

_parseDeclarationBlock

public final void _parseDeclarationBlock()
                                  throws ParseException
Throws:
ParseException

_parseSelectors

public final List<Selector> _parseSelectors()
                                     throws ParseException
Throws:
ParseException

ReInit

public void ReInit(CharStream stream)
Reinitialise.


ReInit

public void ReInit(ParserTokenManager tm)
Reinitialise.


getNextToken

public final Token getNextToken()
Get the next Token.


getToken

public final Token getToken(int index)
Get the specific Token.


generateParseException

public ParseException generateParseException()
Generate ParseException.


enable_tracing

public final void enable_tracing()
Enable tracing.


disable_tracing

public final void disable_tracing()
Disable tracing.



Copyright © 2013–2014 Vaadin. All rights reserved.