UNPKG

@grammar/stylus

Version:

Stylus grammar.

150 lines 4.75 kB
import $ from './spellu-engine'; /** * Stylus - */ declare namespace grammar$stylus.processors { const cst: $.Dictionary<$.Processor>; const ast: $.Dictionary<$.Processor>; } declare namespace grammar$stylus { const enum Syntax { StylusDocument = "stylus.StylusDocument", Statement = "stylus.Statement", Import = "stylus.Import", Ruleset = "stylus.Ruleset", Selector = "stylus.Selector", Tag = "stylus.Tag", Id = "stylus.Id", Class = "stylus.Class", Attribute = "stylus.Attribute", Pseudo = "stylus.Pseudo", Combinator = "stylus.Combinator", Declaration = "stylus.Declaration", Identifier = "stylus.Identifier", Expression = "stylus.Expression", Value = "stylus.Value" } const enum Syntax { IdentToken = "stylus.token.ident", NumberToken = "stylus.token.number", DimensionToken = "stylus.token.dimension", PercentageToken = "stylus.token.percentage", HashToken = "stylus.token.hash", StringToken = "stylus.token.string", IdToken = "stylus.token.id", ClassToken = "stylus.token.class", ImportantToken = "stylus.token.important", ColonToken = "stylus.token.colon" } enum ElementCombinator { Descendant = " ", Child = ">", NextSibling = "+", SubsequentSibling = "~" } enum MatchOperator { WholeMatch = "=", PrefixMatch = "^=", SuffixMatch = "$=", SubstringMatch = "*=", Includes = "~=", DashMatch = "|=" } type Node = Token | StylusDocument | Statement | Selector | SelectorItem | Declaration | Identifier | Expression | Value; interface Token extends $.Token { } interface StylusDocument extends $.Node { syntax: Syntax.StylusDocument; statements: Statement[]; } type Statement = (Statement.Import | Statement.Ruleset); namespace Statement { interface Import extends $.Node { syntax: Syntax.Import; } interface Ruleset extends $.Node { syntax: Syntax.Ruleset; selectors: Selector[]; items: (Declaration | Ruleset)[]; } } interface Selector extends $.Node { syntax: Syntax.Selector; items: SelectorItem[]; } type SelectorItem = SelectorItem.Tag | SelectorItem.Id | SelectorItem.Class | SelectorItem.Attribute | SelectorItem.Pseudo | SelectorItem.Combinator; namespace SelectorItem { interface Tag extends $.Node { syntax: Syntax.Tag; name: string; } interface Id extends $.Node { syntax: Syntax.Id; name: string; } interface Class extends $.Node { syntax: Syntax.Class; name: string; } interface Attribute extends $.Node { syntax: Syntax.Attribute; name: Token; operator?: MatchOperator; value?: Value; } interface Pseudo extends $.Node { syntax: Syntax.Pseudo; name: string; parameter?: SelectorItem; } interface Combinator extends $.Node { syntax: Syntax.Combinator; combinator: ElementCombinator; } } interface Declaration extends $.Node { syntax: Syntax.Declaration; property: Identifier; expressions: Expression[]; important?: boolean; } interface Identifier extends $.Node { syntax: Syntax.Identifier; name: string; token: Token; } interface Expression extends $.Node { syntax: Syntax.Expression; items: Value[]; } interface Value extends $.Node { syntax: Syntax.Value; value: string; token: Token; } } declare namespace grammar$stylus { enum ProcessorSuite { CST = "cst", AST = "ast" } function selectProcessorSuite(suite: ProcessorSuite): $.Processor[]; function scan<V>(source: string | $.SourceDescriptor, suite?: ProcessorSuite, rule?: string, options?: Partial<$.ScanOptions>): V; function tokens(source: string | $.SourceDescriptor, options?: Partial<$.ScanOptions>): Token[]; } declare namespace grammar$stylus { type PrintOptions = { pretty?: boolean; }; export function print(value: StylusDocument, options?: PrintOptions): string; export {}; } declare namespace grammar$stylus.recipes { const stylus: $.Recipe; } declare namespace grammar$stylus.processors { } declare namespace grammar$stylus.processors { } export default grammar$stylus; //# sourceMappingURL=grammar-stylus.d.ts.map