package cnm // Token represents a parsed line in a CNM document. type Token interface { Indent() int Raw() string Line() int } // TokenLine represents an arbitrary CNM line. type TokenLine struct { Indentation int RawLine string LineNo int } // Indent returns the indentation of the parsed line. func (t *TokenLine) Indent() int { return t.Indentation } // Raw returns the original unparsed line. func (t *TokenLine) Raw() string { return t.RawLine } // Line returns the line number in the document, starting from 1. func (t *TokenLine) Line() int { return t.LineNo } // TokenEmptyLine represents an empty line. // // A line is empty as long as it contains up to as many tab characters as the // line's indentation and nothing else. type TokenEmptyLine struct { TokenLine } // TokenBlock represents a block header line. type TokenBlock struct { TokenLine // Parent is the parent block Parent *TokenBlock // Name is the block name. Name string // Args are the block arguments, split by whitespace and then parsed as // simple text. Args []string } // TokenSimpleText represents a line of simple text. type TokenSimpleText struct { TokenLine // Text is the line contents parsed as simple text. Text string } // TokenRawText represents a non-empty line with unparsed contents. type TokenRawText struct { TokenLine // Text is the raw contents of the line with the indentation removed. Text string }