Inherits from PXParserBase
Conforms to PXStylesheetLexerDelegate
Declared in PXStylesheetParser.h

Overview

PXStylesheetParser is responsible for making the first pass on CSS source. This pass generates expression trees for selectors. However, rule set bodies are mostly scanned only. The parser recognizes a declaration’s name (property name), but simply collects its value lexemes in a array for future processing, if needed.

PXStylesheetParser uses some simple strategies for error recovery. All errors are captured and attached to the stylesheet generated by the parse methods.

Tasks

  • – parse:withOrigin:

    Make a first pass parse of the specified source and return the results in a new stylesheet instance.

  • – parse:withOrigin:filename:

    Make a first pass parse of the specified source and return the result in a new stylesheet instance. This parse method allows the file name to be specified which is used to prevent @import cycles.

  • – parseInlineCSS:

    Treat the specified source as inline CSS, as if it were coming from a style attribute.

  • – parseSelectorString:

    Parse the specified source as a CSS selector only.

Instance Methods

parse:withOrigin:

Make a first pass parse of the specified source and return the results in a new stylesheet instance.

- (PXStylesheet *)parse:(NSString *)source withOrigin:(PXStylesheetOrigin)origin

Parameters

source

The CSS to parse

origin

The origin (specificity) to use for the generated stylesheet

Discussion

Make a first pass parse of the specified source and return the results in a new stylesheet instance.

Declared In

PXStylesheetParser.h

parse:withOrigin:filename:

Make a first pass parse of the specified source and return the result in a new stylesheet instance. This parse method allows the file name to be specified which is used to prevent @import cycles.

- (PXStylesheet *)parse:(NSString *)source withOrigin:(PXStylesheetOrigin)origin filename:(NSString *)name

Parameters

source

The CSS to parse

origin

The origin (specificity) to use for the generated stylesheet

name

The name of the file being processed

Discussion

Make a first pass parse of the specified source and return the result in a new stylesheet instance. This parse method allows the file name to be specified which is used to prevent @import cycles.

Declared In

PXStylesheetParser.h

parseInlineCSS:

Treat the specified source as inline CSS, as if it were coming from a style attribute.

- (PXStylesheet *)parseInlineCSS:(NSString *)css

Parameters

css

The inline CSS to parse

Discussion

Treat the specified source as inline CSS, as if it were coming from a style attribute.

Declared In

PXStylesheetParser.h

parseSelectorString:

Parse the specified source as a CSS selector only.

- (id<PXSelector>)parseSelectorString:(NSString *)source

Parameters

source

The selector source

Discussion

Parse the specified source as a CSS selector only.

Declared In

PXStylesheetParser.h