type

BlockParser

src @Js
abstract class BlockParser : Obj

A block parser is able to parse a specific block node.

methods

addLine

Default implementation does nothing with the source line

addSourceSpan

Add a source span of the currently parsed block.

block

Get the parsed block

canContain

Return true if the this block may contain the child block; false otherwise (default)

canHaveLazyContinuationLines

Return true if the block can have lazy continuation lines.

closeBlock

Do any processing when the block is closed

definitions

Return the definitions parsed by this parser.

isContainer

Return true if the block that is parsed is a container (i.e.

parseInlines

Callback to parse inline content

tryContinue

Attempt to continue parsing the block from the given state

Slot Details

addLine

src virtual Void addLine(SourceLine line)

Default implementation does nothing with the source line

addSourceSpan

src virtual Void addSourceSpan(SourceSpan sourceSpan)

Add a source span of the currently parsed block. The default implementation adds it to the block. Unless you have some complicated parsing where you need to check source positions, you don't need to override this.

block

src abstract Block block()

Get the parsed block

canContain

src virtual Bool canContain(Block childBlock)

Return true if the this block may contain the child block; false otherwise (default)

canHaveLazyContinuationLines

src virtual Bool canHaveLazyContinuationLines()

Return true if the block can have lazy continuation lines.

Lazy continuation lines are lines that were rejected by this tryContinue but didn't match any other block parser either.

If true is returned here, those lines will get added via addLine. For false (default), the block is closed instead.

closeBlock

src virtual Void closeBlock()

Do any processing when the block is closed

definitions

src virtual DefinitionMap[] definitions()

Return the definitions parsed by this parser. The definitions returned here can later be accessed during inline parsing.

isContainer

src virtual Bool isContainer()

Return true if the block that is parsed is a container (i.e. contains other blocks), or false (default) if it's a leaf.

parseInlines

src virtual Void parseInlines(InlineParser inlineParser)

Callback to parse inline content

tryContinue

src abstract BlockContinue? tryContinue(ParserState state)

Attempt to continue parsing the block from the given state