Detailed Description

Handles the parsing of CSS content.

Inheritance diagram for Css.CssLexer:
Dom.StringReader

Public Member Functions

 CssLexer (string text, Node scope)
 
Rule ReadRules (out Rule[] set)
 Reads a rule from this lexer. More...
 
Selector ReadSelector ()
 Reads one selector without a block. More...
 
void ReadSelectors (List< Selector > all)
 Reads one or more selectors without a block. More...
 
void SkipJunk ()
 Skips any junk such as whitespaces or comments. More...
 
Css.Value GetVariable (string name)
 Gets the value of a CSS variable from the variable set. More...
 
void AddVariable (string name, Css.Value value)
 Adds a CSS variable to the variable set. More...
 
void ErrorRecovery ()
 Attempt to recover the stream to a new readable state. More...
 
Css.Value ReadFunction (string name)
 Reads a function with the given lowercase name. There must be a bracket at the current read head. More...
 
void SkipBlock ()
 Skips a whole block. More...
 
Css.Value ReadValue ()
 The lexer must be in literal mode for this. Reads a value from the stream. May read a whole set or null if there's a ) or ; at the read head. More...
 
Css.Value ReadLiteralValue ()
 Reads a single value from the stream in literal mode. More...
 
Css.Value ReadSingleValue ()
 Reads a single value from the stream. More...
 
string ReadString ()
 Reads a single value as a string only. More...
 
- Public Member Functions inherited from Dom.StringReader
 StringReader (byte[] str)
 Creates a new reader for the raw single-byte encoded string. Useful if you're talking to e.g. a webserver with a binary protocol. More...
 
 StringReader (string str)
 Creates a new reader for the given string. More...
 
bool More ()
 Checks if there is anything left to read. More...
 
bool Peek (string str)
 Checks if the given string is next. More...
 
bool PeekLower (string str)
 Checks if the given string is next; it checks by lowercasing the target character. More...
 
char Peek ()
 Takes a peek at the next character in the stream without reading it. More...
 
char Peek (int delta)
 Takes a peek at the character that is a number of characters away from the next one without actually reading it. Peek(0) is the next character, Peek(1) is the one after that etc. More...
 
void StepBack ()
 Steps back one place in the stream. More...
 
void Advance ()
 Steps forward one place in the stream. More...
 
void Advance (int places)
 Steps forward the given number of places in the stream. More...
 
int Length ()
 The length of the string. More...
 
string ReadString (int length)
 Reads a substring of the given length. Note that this does not do bounds checking. More...
 
virtual char Read ()
 Reads a character from the stream and advances the stream one place. More...
 
void ReadUntil (char character)
 Keeps reading the given character from the stream until it's no longer next. Used for e.g. stripping an unknown length block of whitespaces in the stream. More...
 
void ReadOff (char[] chars)
 Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream. More...
 
void ReadOff (char[] chars, out int count)
 Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream. More...
 
int NextIndexOf (char character)
 Gets the next index of the given character. The length is returned if it wasn't found at all. More...
 
int NextIndexOf (char character, int limit)
 Gets the next index of the given character, up to limit. Limit is returned if it wasn't found at all. More...
 
virtual int GetLineNumber ()
 Gets the line number that the pointer is currently at. More...
 
int GetLineNumber (out int charOnLine)
 Gets the line number and character number that the pointer is currently at. More...
 
string ReadLine (int lineNumber)
 Reads the numbered line from this stream. More...
 

Static Public Member Functions

static Rule ConvertToRule (Rule parentRule, Css.Value value, StyleSheet sheet, out Rule[] ruleSet)
 Converts a value to a rule. Note that it can be a set of rules (RuleSet). More...
 
static SelectorMatcher ReadSelectorMatcher (Css.Value value)
 Reads a single selector matcher. E.g. :hover or .test More...
 
static Selector ReadSelectors (StyleSheet sheet, Css.Value value, List< Selector > all)
 Reads one or more selectors from the given value. More...
 
- Static Public Member Functions inherited from Dom.StringReader
static int NextIndexOf (int position, string input, char character, int limit)
 Gets the next index of the given character, up to limit. Limit is returned if it wasn't found at all. More...
 
static int NextIndexOf (int position, string input, char character)
 Gets the next index of the given character. The length is returned if it wasn't found at all. More...
 

Public Attributes

StringBuilder Builder =new StringBuilder()
 A builder used when parsing text. More...
 
bool PropertyMapMode
 True if any {selector blocks} should be parsed as literal property maps. used by e.g. the rule. More...
 
bool AtRuleMode
 True if we're in mode. More...
 
Node Scope
 The current scope of this lexer. More...
 
StyleSheet Sheet
 Current stylesheet. More...
 
bool SelectorMode
 Are we reading the selector? More...
 
Css.Rule LatestRule
 The latest parent rule. More...
 
- Public Attributes inherited from Dom.StringReader
string Input
 The original string. More...
 
int Position
 The current position this reader is at in the string. More...
 
int InputLength
 The length of the input string. More...
 

Properties

ReflowDocument Document [get]
 The document this lexer is working with. More...
 
Dictionary< string, Css.ValueVariables [get]
 Css variables, if any. More...
 

Private Member Functions

void ErrorSkipBlock ()
 Skips a curley bracket block. More...
 
void ApplyList (Value set, List< Value > values)
 

Static Private Member Functions

static RootUniversalMatcher CreateUniversal (List< RootMatcher > roots)
 Creates an * node and adds it to the given set. More...
 
static Selector LoadSingleSelector (StyleSheet sheet, Css.Value value, List< Selector > all)
 

Additional Inherited Members

- Static Public Attributes inherited from Dom.StringReader
static char NULL ='\0'
 The null character. This is returned when operations are working beyond the end of the stream. More...
 

Constructor & Destructor Documentation

Css.CssLexer.CssLexer ( string  text,
Node  scope 
)
inline

Member Function Documentation

void Css.CssLexer.AddVariable ( string  name,
Css.Value  value 
)
inline

Adds a CSS variable to the variable set.

void Css.CssLexer.ApplyList ( Value  set,
List< Value values 
)
inlineprivate
static Rule Css.CssLexer.ConvertToRule ( Rule  parentRule,
Css.Value  value,
StyleSheet  sheet,
out Rule[]  ruleSet 
)
inlinestatic

Converts a value to a rule. Note that it can be a set of rules (RuleSet).

static RootUniversalMatcher Css.CssLexer.CreateUniversal ( List< RootMatcher roots)
inlinestaticprivate

Creates an * node and adds it to the given set.

void Css.CssLexer.ErrorRecovery ( )
inline

Attempt to recover the stream to a new readable state.

void Css.CssLexer.ErrorSkipBlock ( )
inlineprivate

Skips a curley bracket block.

Css.Value Css.CssLexer.GetVariable ( string  name)
inline

Gets the value of a CSS variable from the variable set.

static Selector Css.CssLexer.LoadSingleSelector ( StyleSheet  sheet,
Css.Value  value,
List< Selector all 
)
inlinestaticprivate
Css.Value Css.CssLexer.ReadFunction ( string  name)
inline

Reads a function with the given lowercase name. There must be a bracket at the current read head.

Css.Value Css.CssLexer.ReadLiteralValue ( )
inline

Reads a single value from the stream in literal mode.

Rule Css.CssLexer.ReadRules ( out Rule[]  set)
inline

Reads a rule from this lexer.

Selector Css.CssLexer.ReadSelector ( )
inline

Reads one selector without a block.

static SelectorMatcher Css.CssLexer.ReadSelectorMatcher ( Css.Value  value)
inlinestatic

Reads a single selector matcher. E.g. :hover or .test

void Css.CssLexer.ReadSelectors ( List< Selector all)
inline

Reads one or more selectors without a block.

static Selector Css.CssLexer.ReadSelectors ( StyleSheet  sheet,
Css.Value  value,
List< Selector all 
)
inlinestatic

Reads one or more selectors from the given value.

Css.Value Css.CssLexer.ReadSingleValue ( )
inline

Reads a single value from the stream.

string Css.CssLexer.ReadString ( )
inline

Reads a single value as a string only.

Css.Value Css.CssLexer.ReadValue ( )
inline

The lexer must be in literal mode for this. Reads a value from the stream. May read a whole set or null if there's a ) or ; at the read head.

void Css.CssLexer.SkipBlock ( )
inline

Skips a whole block.

void Css.CssLexer.SkipJunk ( )
inline

Skips any junk such as whitespaces or comments.

Member Data Documentation

bool Css.CssLexer.AtRuleMode

True if we're in mode.

StringBuilder Css.CssLexer.Builder =new StringBuilder()

A builder used when parsing text.

Css.Rule Css.CssLexer.LatestRule

The latest parent rule.

bool Css.CssLexer.PropertyMapMode

True if any {selector blocks} should be parsed as literal property maps. used by e.g. the rule.

Node Css.CssLexer.Scope

The current scope of this lexer.

bool Css.CssLexer.SelectorMode

Are we reading the selector?

StyleSheet Css.CssLexer.Sheet

Current stylesheet.

Property Documentation

ReflowDocument Css.CssLexer.Document
get

The document this lexer is working with.

Dictionary<string,Css.Value> Css.CssLexer.Variables
get

Css variables, if any.