org.w3c.flute.parser

Class Parser

Implemented Interfaces:
org.w3c.css.sac.Parser, ParserConstants

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

A CSS2 parser
Version:
$Revision: 1.4 $
Author:
Philippe Le Higaret

Field Summary

protected ConditionFactory
conditionFactory
protected DocumentHandler
documentHandler
protected ErrorHandler
errorHandler
Token
jj_nt
boolean
lookingAhead
protected String
pseudoElt
protected SelectorFactory
selectorFactory
protected InputSource
source
Token
token
ParserTokenManager
token_source

Fields inherited from interface org.w3c.flute.parser.ParserConstants

ANY, ATKEYWORD, CDC, CDO, CHARSET_SYM, CM, COLON, COMMA, D, DASHMATCH, DEFAULT, DEG, DIMEN, DIV, DOT, EMS, EOF, EQ, ESCAPE, EXS, FONT_FACE_SYM, FUNCTION, GRAD, H, HASH, HZ, IDENT, IMPORTANT_SYM, IMPORT_SYM, IN, INCLUDES, IN_COMMENT, KHZ, LBRACE, LBRACKET, LPARAN, MEDIA_SYM, MINUS, MM, MS, NAME, NAMESPACE_IDENT, NAMESPACE_SYM, NMCHAR, NMSTART, NNAME, NONASCII, NUMBER, PAGE_SYM, PC, PERCENTAGE, PLUS, PRECEDES, PT, PX, RAD, RANGE, RANGE0, RANGE1, RANGE2, RANGE3, RANGE4, RANGE5, RANGE6, RBRACE, RBRACKET, RPARAN, S, SECOND, SEMICOLON, STRING, STRINGCHAR, UNI, UNICODE, UNICODERANGE, UNKNOWN, URL, _URL, tokenImage

Constructor Summary

Parser()
Creates a new Parser
Parser(CharStream stream)
Parser(ParserTokenManager tm)

Method Summary

void
ReInit(CharStream stream)
void
ReInit(ParserTokenManager tm)
Condition
_class(Condition pred)
void
_parseDeclarationBlock()
void
_parseImportRule()
void
_parseMediaRule()
String
_parseNamespaceToken()
void
_parseRule()
The following functions are useful for a DOM CSS implementation only and are not part of the general CSS2 parser.
SelectorList
_parseSelectors()
void
afterImportDeclaration()
void
atRuleDeclaration()
Condition
attrib(Condition pred)
void
charset()
char
combinator()
void
declaration()
void
disable_tracing()
SimpleSelector
element_name()
void
enable_tracing()
LexicalUnit
expr()
void
fontFace()
org.w3c.flute.parser.LexicalUnitImpl
function(char operator, org.w3c.flute.parser.LexicalUnitImpl prev)
Handle all CSS2 functions.
ParseException
generateParseException()
Token
getNextToken()
String
getParserVersion()
This methods returns "http://www.w3.org/TR/REC-CSS2".
Token
getToken(int index)
Condition
hash(Condition pred)
org.w3c.flute.parser.LexicalUnitImpl
hexcolor(org.w3c.flute.parser.LexicalUnitImpl prev)
void
ignoreStatement()
void
importDeclaration()
The import statement
void
media()
void
mediaStatement(MediaListImpl ml)
String
medium()
void
namespaceDeclaration()
The namespace statement
org.w3c.flute.parser.LexicalUnitImpl
operator(org.w3c.flute.parser.LexicalUnitImpl prev)
void
page()
void
parseImportRule(InputSource source)
Parse methods used by DOM Level 2 implementation.
void
parseMediaRule(InputSource source)
String
parseNamespaceToken(InputSource source)
boolean
parsePriority(InputSource source)
LexicalUnit
parsePropertyValue(InputSource source)
void
parseRule(InputSource source)
This method parses only one rule (style rule or at-rule, except @charset).
SelectorList
parseSelectors(InputSource source)
void
parseStyleDeclaration(InputSource source)
This method parses a style declaration (including the surrounding curly braces).
void
parseStyleSheet(InputSource source)
Main parse methods
void
parseStyleSheet(String systemId)
Convenient method for URIs.
void
parserUnit()
The main entry for the parser.
boolean
prio()
String
property()
Condition
pseudo(Condition pred)
String
pseudo_page()
Selector
selector()
SelectorList
selectorList()
void
setConditionFactory(ConditionFactory conditionFactory)
void
setDocumentHandler(DocumentHandler handler)
Set the document handler for this parser
void
setErrorHandler(ErrorHandler error)
Set the error handler for this parser
void
setLocale(Locale locale)
void
setSelectorFactory(SelectorFactory selectorFactory)
Selector
simple_selector(Selector selector, char comb)
void
skipUnknownRule()
void
styleRule()
org.w3c.flute.parser.LexicalUnitImpl
term(org.w3c.flute.parser.LexicalUnitImpl prev)
char
unaryOperator()
org.w3c.flute.parser.LexicalUnitImpl
unicode(org.w3c.flute.parser.LexicalUnitImpl prev)
org.w3c.flute.parser.LexicalUnitImpl
url(org.w3c.flute.parser.LexicalUnitImpl prev)

Field Details

conditionFactory

protected ConditionFactory conditionFactory

documentHandler

protected DocumentHandler documentHandler

errorHandler

protected ErrorHandler errorHandler

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead

pseudoElt

protected String pseudoElt

selectorFactory

protected SelectorFactory selectorFactory

source

protected InputSource source

token

public Token token

token_source

public ParserTokenManager token_source

Constructor Details

Parser

public Parser()
Creates a new Parser

Parser

public Parser(CharStream stream)

Parser

public Parser(ParserTokenManager tm)

Method Details

ReInit

public void ReInit(CharStream stream)

ReInit

public void ReInit(ParserTokenManager tm)

_class

public final Condition _class(Condition pred)
            throws ParseException
Throws:
ParseException - exception during the parse

_parseDeclarationBlock

public final void _parseDeclarationBlock()
            throws ParseException

_parseImportRule

public final void _parseImportRule()
            throws ParseException

_parseMediaRule

public final void _parseMediaRule()
            throws ParseException

_parseNamespaceToken

public final String _parseNamespaceToken()
            throws ParseException

_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.

_parseSelectors

public final SelectorList _parseSelectors()
            throws ParseException

afterImportDeclaration

public final void afterImportDeclaration()
            throws ParseException

atRuleDeclaration

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

attrib

public final Condition attrib(Condition pred)
            throws ParseException
Throws:
ParseException - exception during the parse

charset

public final void charset()
            throws ParseException

combinator

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

declaration

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

disable_tracing

public final void disable_tracing()

element_name

public final SimpleSelector element_name()
            throws ParseException
Throws:
ParseException - exception during the parse

enable_tracing

public final void enable_tracing()

expr

public final LexicalUnit expr()
            throws ParseException
Throws:
ParseException - exception during the parse

fontFace

public final void fontFace()
            throws ParseException

function

public final org.w3c.flute.parser.LexicalUnitImpl function(char operator,
                                                           org.w3c.flute.parser.LexicalUnitImpl prev)
            throws ParseException
Handle all CSS2 functions.
Throws:
ParseException - exception during the parse

generateParseException

public ParseException generateParseException()

getNextToken

public final Token getNextToken()

getParserVersion

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

getToken

public final Token getToken(int index)

hash

public final Condition hash(Condition pred)
            throws ParseException
Throws:
ParseException - exception during the parse

hexcolor

public final org.w3c.flute.parser.LexicalUnitImpl hexcolor(org.w3c.flute.parser.LexicalUnitImpl prev)
            throws ParseException
Throws:
ParseException - exception during the parse

ignoreStatement

public final void ignoreStatement()
            throws ParseException

importDeclaration

public final void importDeclaration()
            throws ParseException
The import statement
Throws:
ParseException - exception during the parse

media

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

mediaStatement

public final void mediaStatement(MediaListImpl ml)
            throws ParseException

medium

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

namespaceDeclaration

public final void namespaceDeclaration()
            throws ParseException
The namespace statement
Throws:
ParseException - exception during the parse

operator

public final org.w3c.flute.parser.LexicalUnitImpl operator(org.w3c.flute.parser.LexicalUnitImpl prev)
            throws ParseException
Throws:
ParseException - exception during the parse

page

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

parseImportRule

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

parseMediaRule

public void parseMediaRule(InputSource source)
            throws CSSException,
                   IOException

parseNamespaceToken

public String parseNamespaceToken(InputSource source)
            throws CSSException,
                   IOException

parsePriority

public boolean parsePriority(InputSource source)
            throws CSSException,
                   IOException

parsePropertyValue

public LexicalUnit parsePropertyValue(InputSource source)
            throws CSSException,
                   IOException

parseRule

public void parseRule(InputSource source)
            throws CSSException,
                   IOException
This method parses only one rule (style rule or at-rule, except @charset).
Parameters:
source - the source of the rule.

parseSelectors

public SelectorList parseSelectors(InputSource source)
            throws CSSException,
                   IOException

parseStyleDeclaration

public void parseStyleDeclaration(InputSource source)
            throws CSSException,
                   IOException
This method parses a style declaration (including the surrounding curly braces).
Parameters:
source - the source of the style declaration.

parseStyleSheet

public void parseStyleSheet(InputSource source)
            throws CSSException,
                   IOException
Main parse methods
Parameters:
source - the source of the style sheet.

parseStyleSheet

public void parseStyleSheet(String systemId)
            throws CSSException,
                   IOException
Convenient method for URIs.
Parameters:
systemId - the fully resolved URI of the style sheet.

parserUnit

public final void parserUnit()
            throws ParseException
The main entry for the parser.
Throws:
ParseException - exception during the parse

prio

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

property

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

pseudo

public final Condition pseudo(Condition pred)
            throws ParseException
Throws:
ParseException - exception during the parse

pseudo_page

public final String pseudo_page()
            throws ParseException

selector

public final Selector selector()
            throws ParseException
Throws:
ParseException - exception during the parse

selectorList

public final SelectorList selectorList()
            throws ParseException

setConditionFactory

public void setConditionFactory(ConditionFactory conditionFactory)

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)
Set the document handler for this parser

setErrorHandler

public void setErrorHandler(ErrorHandler error)
Set the error handler for this parser

setLocale

public void setLocale(Locale locale)
            throws CSSException

setSelectorFactory

public void setSelectorFactory(SelectorFactory selectorFactory)

simple_selector

public final Selector simple_selector(Selector selector,
                                      char comb)
            throws ParseException
Throws:
ParseException - exception during the parse

skipUnknownRule

public final void skipUnknownRule()
            throws ParseException

styleRule

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

term

public final org.w3c.flute.parser.LexicalUnitImpl term(org.w3c.flute.parser.LexicalUnitImpl prev)
            throws ParseException
Throws:
ParseException - exception during the parse

unaryOperator

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

unicode

public final org.w3c.flute.parser.LexicalUnitImpl unicode(org.w3c.flute.parser.LexicalUnitImpl prev)
            throws ParseException

url

public final org.w3c.flute.parser.LexicalUnitImpl url(org.w3c.flute.parser.LexicalUnitImpl prev)
            throws ParseException