sidekick.css.parser
Class CSS3Parser

java.lang.Object
  extended by sidekick.css.parser.CSS3Parser
All Implemented Interfaces:
CSS3ParserConstants

public class CSS3Parser
extends java.lang.Object
implements CSS3ParserConstants

A CSS3 parser

Version:
Revision: 1.71 (W3C version)
Author:
Philippe Le Hegaret and Sijtsche Smeman, Dale Anson, major modifications for jEdit Sidekick

Field Summary
 Token jj_nt
          Next token.
 Token token
          Current token.
 CSS3ParserTokenManager token_source
          Generated Token Manager.
static java.util.HashSet<java.lang.String> unsupportedPropertyNames
           
 
Fields inherited from interface sidekick.css.parser.CSS3ParserConstants
_IDENT, _INVALID, _S, _STRING, _URL, _W, AND, ANGLE, ANY, ATBOTTOM, ATCOUNTER, ATKEYWORD, ATLEFT, ATRIGHT, ATTOP, CDC, CDO, CHARSET_SYM, CLASS, COLON, COLOR_PROFILE, COMMA, COMMENT, DASHMATCH, DATE, DEFAULT, DIMEN, DIV, DOT, EMS, EOF, EQ, ESCAPE, EXS, FONT_FACE_SYM, FREQ, FUNCTION, FUNCTIONLANG, FUNCTIONNOT, GREATER, H, HASH, HASHIDENT, HTMLENDTAG, HTMLSTARTTAG, IDENT, IMPORT_SYM, IMPORTANT_SYM, INCLUDES, INVALID, INVALID1, INVALID2, LBRACE, LBRACKET, LENGTH, LPARAN, MEDIA_SYM, MEDIARESTRICTOR, MINUS, NAME, NAMESPACE_SYM, NL, NMCHAR, NMSTART, NONASCII, NUM, NUMBER, PAGE_SYM, PERCENTAGE, PHONETIC_ALPHABET_SYM, PLUS, PREF_SYM, PREFIXMATCH, PSEUDOELEMENT_SYM, RANGE, RANGE0, RANGE1, RANGE2, RANGE3, RANGE4, RANGE5, RANGE6, RBRACE, RBRACKET, RESOLUTION, RPARAN, S, SEMICOLON, STRING, STRING1, STRING2, SUBSTRINGMATCH, SUFFIXMATCH, TILDE, TIME, tokenImage, UNI, UNICODE, UNICODERANGE, URL
 
Constructor Summary
CSS3Parser(CSS3ParserTokenManager tm)
          Constructor with generated Token Manager.
CSS3Parser(java.io.InputStream stream)
          Constructor with InputStream.
CSS3Parser(java.io.InputStream stream, java.lang.String encoding)
          Constructor with InputStream and supplied encoding
CSS3Parser(java.io.Reader stream)
          Constructor.
CSS3Parser(java.io.Reader in, int lineOffset, int columnOffset)
          The line offset is used when the css to be parsed is only part of a file, for example when the css is the contents of a style block contained within an html document.
 
Method Summary
 CSSNode _class()
           
 java.util.List<CSSNode> afterImportDeclaration()
           
 CSSNode atRuleDeclaration()
           
 CSSNode attrib()
           
 CSSNode charset()
           
 CSSNode colorprofile()
           
 char combinator()
           
 CSSNode createNode(Token t)
          Creates a CSSNode from a token using the token image as the node name and the token start and end for node start and end locations.
 CSSNode declaration()
           
 java.util.List<CSSNode> declarations()
           
 CSSNode definition()
           
 CSSNode deprecated_class()
           
 void disable_tracing()
          Disable tracing.
 CSSNode element_name()
           
 void enable_tracing()
          Enable tracing.
 void error_skipto(int kind)
           
 CSSNode expr()
           
 CSSNode expression()
           
 CSSNode externalSelector()
          I made this rule to parse a selector from a document.
 CSSNode fontFace()
           
 CSSNode function()
           
 ParseException generateParseException()
          Generate ParseException.
 sidekick.util.Location getEndLocation(Token t)
           
 Token getNextToken()
          Get the next Token.
 java.util.List<sidekick.util.ParseError> getParseErrors()
           
 java.util.List<sidekick.util.ParseError> getParseWarnings()
           
 sidekick.util.Location getStartLocation(Token t)
           
 int getTabSize()
           
 Token getToken(int index)
          Get the specific Token.
 CSSNode hash()
           
 CSSNode hexcolor()
           
 void ignoreStatement()
           
 CSSNode importDeclaration()
          The import statement
 boolean isUnsupported(java.lang.String propertyName)
           
static void main(java.lang.String[] args)
           
 CSSNode media()
           
 CSSNode mediadeclaration()
           
 CSSNode medium()
           
 CSSNode namespaceDeclaration()
           
 CSSNode negation()
           
 boolean notNull(java.lang.Object... args)
          Simple check to verify that all arguments are not null.
 char operator()
           
 CSSNode page()
           
 java.util.List<CSSNode> pageContent()
           
 CSSNode phoneticAlphabet()
           
 CSSNode prefAtRule()
           
 CSSNode preference()
           
 CSSNode prio()
           
 CSSNode property()
           
 CSSNode pseudo_page()
           
 CSSNode pseudo()
           
 void ReInit(CSS3ParserTokenManager tm)
          Reinitialise.
 void ReInit(java.io.InputStream stream)
          Reinitialise.
 void ReInit(java.io.InputStream stream, java.lang.String encoding)
          Reinitialise.
 void ReInit(java.io.Reader stream)
          Reinitialise.
 CSSNode ruleSet()
           
 CSSNode selector()
           
 void setProprietaryAsError(boolean b)
          If set to true, then a warning will be generated when proprietary CSS markup is used.
 void setTabSize(int size)
          Set the tab size on the input stream.
 CSSNode simple_selector()
           
 CSSNode styleSheet()
          The main entry for the parser.
 CSSNode term()
           
 char unaryOperator()
           
 CSSNode unused_production_generic_syntax()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unsupportedPropertyNames

public static final java.util.HashSet<java.lang.String> unsupportedPropertyNames

token_source

public CSS3ParserTokenManager token_source
Generated Token Manager.


token

public Token token
Current token.


jj_nt

public Token jj_nt
Next token.

Constructor Detail

CSS3Parser

public CSS3Parser(java.io.Reader in,
                  int lineOffset,
                  int columnOffset)
The line offset is used when the css to be parsed is only part of a file, for example when the css is the contents of a style block contained within an html document.

Parameters:
lineOffset - The line number of the first line of the css.
columnOffset - The column number of the first character of the css.

CSS3Parser

public CSS3Parser(java.io.InputStream stream)
Constructor with InputStream.


CSS3Parser

public CSS3Parser(java.io.InputStream stream,
                  java.lang.String encoding)
Constructor with InputStream and supplied encoding


CSS3Parser

public CSS3Parser(java.io.Reader stream)
Constructor.


CSS3Parser

public CSS3Parser(CSS3ParserTokenManager tm)
Constructor with generated Token Manager.

Method Detail

setTabSize

public void setTabSize(int size)
Set the tab size on the input stream. This should be set to the same tab size as used in the buffer being parsed, otherwise, locations will be off.


getTabSize

public int getTabSize()
Returns:
the current tab size used by the input stream.

setProprietaryAsError

public void setProprietaryAsError(boolean b)
If set to true, then a warning will be generated when proprietary CSS markup is used.

Parameters:
b - If set to true, then a warning will be generated when proprietary CSS markup is used.

getParseErrors

public java.util.List<sidekick.util.ParseError> getParseErrors()
Returns:
The list of parse exceptions found during parsing of a file.

getParseWarnings

public java.util.List<sidekick.util.ParseError> getParseWarnings()

error_skipto

public void error_skipto(int kind)

getStartLocation

public sidekick.util.Location getStartLocation(Token t)
Parameters:
t - A token to create a location from.
Returns:
A location representing the start of the token.

getEndLocation

public sidekick.util.Location getEndLocation(Token t)
Parameters:
t - A token to create a location from.
Returns:
A location representing the end of the token.

createNode

public CSSNode createNode(Token t)
Creates a CSSNode from a token using the token image as the node name and the token start and end for node start and end locations.


notNull

public boolean notNull(java.lang.Object... args)
Simple check to verify that all arguments are not null.


isUnsupported

public boolean isUnsupported(java.lang.String propertyName)

main

public static void main(java.lang.String[] args)

styleSheet

public final CSSNode styleSheet()
                         throws ParseException
The main entry for the parser. The W3C version called this method "parserUnit". I changed the name so it matches up with the older CSS2 parser.

Throws:
ParseException - exception during the parse

charset

public final CSSNode charset()
                      throws ParseException
Throws:
ParseException

afterImportDeclaration

public final java.util.List<CSSNode> afterImportDeclaration()
                                                     throws ParseException
Throws:
ParseException

ignoreStatement

public final void ignoreStatement()
                           throws ParseException
Throws:
ParseException

namespaceDeclaration

public final CSSNode namespaceDeclaration()
                                   throws ParseException
Throws:
ParseException

importDeclaration

public final CSSNode importDeclaration()
                                throws ParseException
The import statement

Throws:
ParseException - exception during the parse

media

public final CSSNode media()
                    throws ParseException
Throws:
ParseException

medium

public final CSSNode medium()
                     throws ParseException
Throws:
ParseException

unused_production_generic_syntax

public final CSSNode unused_production_generic_syntax()
                                               throws ParseException
Throws:
ParseException

definition

public final CSSNode definition()
                         throws ParseException
Throws:
ParseException

page

public final CSSNode page()
                   throws ParseException
Throws:
ParseException

pageContent

public final java.util.List<CSSNode> pageContent()
                                          throws ParseException
Throws:
ParseException

prefAtRule

public final CSSNode prefAtRule()
                         throws ParseException
Throws:
ParseException

pseudo_page

public final CSSNode pseudo_page()
                          throws ParseException
Throws:
ParseException

fontFace

public final CSSNode fontFace()
                       throws ParseException
Throws:
ParseException

colorprofile

public final CSSNode colorprofile()
                           throws ParseException
Throws:
ParseException

preference

public final CSSNode preference()
                         throws ParseException
Throws:
ParseException

phoneticAlphabet

public final CSSNode phoneticAlphabet()
                               throws ParseException
Throws:
ParseException

atRuleDeclaration

public final CSSNode atRuleDeclaration()
                                throws ParseException
Throws:
ParseException

operator

public final char operator()
                    throws ParseException
Throws:
ParseException

combinator

public final char combinator()
                      throws ParseException
Throws:
ParseException

unaryOperator

public final char unaryOperator()
                         throws ParseException
Throws:
ParseException

property

public final CSSNode property()
                       throws ParseException
Throws:
ParseException

ruleSet

public final CSSNode ruleSet()
                      throws ParseException
Throws:
ParseException

declarations

public final java.util.List<CSSNode> declarations()
                                           throws ParseException
Throws:
ParseException

selector

public final CSSNode selector()
                       throws ParseException
Throws:
ParseException

externalSelector

public final CSSNode externalSelector()
                               throws ParseException
I made this rule to parse a selector from a document. Combinator are avoid.

Throws:
ParseException - exception during the parse

simple_selector

public final CSSNode simple_selector()
                              throws ParseException
Throws:
ParseException

_class

public final CSSNode _class()
                     throws ParseException
Throws:
ParseException

deprecated_class

public final CSSNode deprecated_class()
                               throws ParseException
Throws:
ParseException

element_name

public final CSSNode element_name()
                           throws ParseException
Throws:
ParseException

attrib

public final CSSNode attrib()
                     throws ParseException
Throws:
ParseException

negation

public final CSSNode negation()
                       throws ParseException
Throws:
ParseException

pseudo

public final CSSNode pseudo()
                     throws ParseException
Throws:
ParseException

hash

public final CSSNode hash()
                   throws ParseException
Throws:
ParseException

mediadeclaration

public final CSSNode mediadeclaration()
                               throws ParseException
Throws:
ParseException

declaration

public final CSSNode declaration()
                          throws ParseException
Throws:
ParseException

prio

public final CSSNode prio()
                   throws ParseException
Throws:
ParseException

expression

public final CSSNode expression()
                         throws ParseException
Throws:
ParseException

expr

public final CSSNode expr()
                   throws ParseException
Throws:
ParseException

term

public final CSSNode term()
                   throws ParseException
Throws:
ParseException

function

public final CSSNode function()
                       throws ParseException
Throws:
ParseException

hexcolor

public final CSSNode hexcolor()
                       throws ParseException
Throws:
ParseException

ReInit

public void ReInit(java.io.InputStream stream)
Reinitialise.


ReInit

public void ReInit(java.io.InputStream stream,
                   java.lang.String encoding)
Reinitialise.


ReInit

public void ReInit(java.io.Reader stream)
Reinitialise.


ReInit

public void ReInit(CSS3ParserTokenManager 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.