// Generated by Lisette bindgen
// Source: text/template/parse (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.20

pub enum NodeType: int {
  NodeAction = 1,
  NodeBool = 2,
  NodeBreak = 21,
  NodeChain = 3,
  NodeCommand = 4,
  NodeComment = 20,
  NodeContinue = 22,
  NodeDot = 5,
  NodeField = 8,
  NodeIdentifier = 9,
  NodeIf = 10,
  NodeList = 11,
  NodeNil = 12,
  NodeNumber = 13,
  NodePipe = 14,
  NodeRange = 15,
  NodeString = 16,
  NodeTemplate = 17,
  NodeText = 0,
  NodeVariable = 18,
  NodeWith = 19,
}

pub const NodeAction: NodeType = 1

pub const NodeBool: NodeType = 2

pub const NodeBreak: NodeType = 21

pub const NodeChain: NodeType = 3

pub const NodeCommand: NodeType = 4

pub const NodeComment: NodeType = 20

pub const NodeContinue: NodeType = 22

pub const NodeDot: NodeType = 5

pub const NodeField: NodeType = 8

pub const NodeIdentifier: NodeType = 9

pub const NodeIf: NodeType = 10

pub const NodeList: NodeType = 11

pub const NodeNil: NodeType = 12

pub const NodeNumber: NodeType = 13

pub const NodePipe: NodeType = 14

pub const NodeRange: NodeType = 15

pub const NodeString: NodeType = 16

pub const NodeTemplate: NodeType = 17

pub const NodeText: NodeType = 0

pub const NodeVariable: NodeType = 18

pub const NodeWith: NodeType = 19

/// IsEmptyTree reports whether this tree (node) is empty of everything but space or comments.
pub fn IsEmptyTree(n: Node) -> bool

pub fn New(name: string, funcs: VarArgs<Map<string, Unknown>>) -> Ref<Tree>

pub fn NewIdentifier(ident: string) -> Ref<IdentifierNode>

/// Parse returns a map from template name to [Tree], created by parsing the
/// templates described in the argument string. The top-level template will be
/// given the specified name. If an error is encountered, parsing stops and an
/// empty map is returned with the error.
pub fn Parse(
  name: string,
  text: string,
  leftDelim: string,
  rightDelim: string,
  funcs: VarArgs<Map<string, Unknown>>,
) -> Result<Map<string, Ref<Tree>>, error>

/// ActionNode holds an action (something bounded by delimiters).
/// Control actions have their own nodes; ActionNode represents simple
/// ones such as field evaluations and parenthesized pipelines.
pub struct ActionNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Line: int,
  pub Pipe: Option<Ref<PipeNode>>,
}

/// BoolNode holds a boolean constant.
pub struct BoolNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub True: bool,
}

/// BranchNode is the common representation of if, range, and with.
pub struct BranchNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Line: int,
  pub Pipe: Option<Ref<PipeNode>>,
  pub List: Option<Ref<ListNode>>,
  pub ElseList: Option<Ref<ListNode>>,
}

/// BreakNode represents a {{break}} action.
pub struct BreakNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Line: int,
}

/// ChainNode holds a term followed by a chain of field accesses (identifier starting with '.').
/// The names may be chained ('.x.y').
/// The periods are dropped from each ident.
pub struct ChainNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Node: Option<Node>,
  pub Field: Slice<string>,
}

/// CommandNode holds a command (a pipeline inside an evaluating action).
pub struct CommandNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Args: Slice<Option<Node>>,
}

/// CommentNode holds a comment.
pub struct CommentNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Text: string,
}

/// ContinueNode represents a {{continue}} action.
pub struct ContinueNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Line: int,
}

/// DotNode holds the special identifier '.'.
pub struct DotNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
}

/// FieldNode holds a field (identifier starting with '.').
/// The names may be chained ('.x.y').
/// The period is dropped from each ident.
pub struct FieldNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Ident: Slice<string>,
}

/// IdentifierNode holds an identifier.
pub struct IdentifierNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Ident: string,
}

/// IfNode represents an {{if}} action and its commands.
pub struct IfNode {
  pub BranchNode: BranchNode,
}

/// ListNode holds a sequence of nodes.
pub struct ListNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Nodes: Slice<Option<Node>>,
}

/// A mode value is a set of flags (or 0). Modes control parser behavior.
pub struct Mode(uint)

/// NilNode holds the special identifier 'nil' representing an untyped nil constant.
pub struct NilNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
}

/// A Node is an element in the parse tree. The interface is trivial.
/// The interface contains an unexported method so that only
/// types local to this package can satisfy it.
pub interface Node {
  fn Copy() -> Node
  fn Position() -> Pos
  fn String() -> string
  fn Type() -> NodeType
}

/// NumberNode holds a number: signed or unsigned integer, float, or complex.
/// The value is parsed and stored under all the types that can represent the value.
/// This simulates in a small amount of code the behavior of Go's ideal constants.
pub struct NumberNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub IsInt: bool,
  pub IsUint: bool,
  pub IsFloat: bool,
  pub IsComplex: bool,
  pub Int64: int64,
  pub Uint64: uint64,
  pub Float64: float64,
  pub Complex128: complex128,
  pub Text: string,
}

/// PipeNode holds a pipeline with optional declaration
pub struct PipeNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Line: int,
  pub IsAssign: bool,
  pub Decl: Slice<Option<Ref<VariableNode>>>,
  pub Cmds: Slice<Option<Ref<CommandNode>>>,
}

/// Pos represents a byte position in the original input text from which
/// this template was parsed.
pub struct Pos(int)

/// RangeNode represents a {{range}} action and its commands.
pub struct RangeNode {
  pub BranchNode: BranchNode,
}

/// StringNode holds a string constant. The value has been "unquoted".
pub struct StringNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Quoted: string,
  pub Text: string,
}

/// TemplateNode represents a {{template}} action.
pub struct TemplateNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Line: int,
  pub Name: string,
  pub Pipe: Option<Ref<PipeNode>>,
}

/// TextNode holds plain text.
pub struct TextNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Text: Slice<uint8>,
}

/// Tree is the representation of a single parsed template.
pub struct Tree {
  pub Name: string,
  pub ParseName: string,
  pub Root: Option<Ref<ListNode>>,
  pub Mode: Mode,
}

/// VariableNode holds a list of variable names, possibly with chained field
/// accesses. The dollar sign is part of the (first) name.
pub struct VariableNode {
  pub NodeType: NodeType,
  pub Pos: Pos,
  pub Ident: Slice<string>,
}

/// WithNode represents a {{with}} action and its commands.
pub struct WithNode {
  pub BranchNode: BranchNode,
}

pub const ParseComments: Mode = 1

pub const SkipFuncCheck: Mode = 2

impl ActionNode {
  fn Copy(self: Ref<ActionNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<ActionNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl BoolNode {
  fn Copy(self: Ref<BoolNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<BoolNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl BranchNode {
  fn Copy(self: Ref<BranchNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<BranchNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl BreakNode {
  fn Copy(self: Ref<BreakNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<BreakNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl ChainNode {
  /// Add adds the named field (which should start with a period) to the end of the chain.
  fn Add(self: Ref<ChainNode>, field: string)

  fn Copy(self: Ref<ChainNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<ChainNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl CommandNode {
  fn Copy(self: Ref<CommandNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<CommandNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl CommentNode {
  fn Copy(self: Ref<CommentNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<CommentNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl ContinueNode {
  fn Copy(self: Ref<ContinueNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<ContinueNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl DotNode {
  fn Copy(self: Ref<DotNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<DotNode>) -> string

  fn Type(self: Ref<DotNode>) -> NodeType
}

impl FieldNode {
  fn Copy(self: Ref<FieldNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<FieldNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl IdentifierNode {
  fn Copy(self: Ref<IdentifierNode>) -> Node

  fn Position(self) -> Pos

  /// SetPos sets the position. [NewIdentifier] is a public method so we can't modify its signature.
  /// Chained for convenience.
  /// TODO: fix one day?
  #[allow(unused_value)]
  fn SetPos(self: Ref<IdentifierNode>, pos: Pos) -> Ref<IdentifierNode>

  /// SetTree sets the parent tree for the node. [NewIdentifier] is a public method so we can't modify its signature.
  /// Chained for convenience.
  /// TODO: fix one day?
  #[allow(unused_value)]
  fn SetTree(self: Ref<IdentifierNode>, t: Ref<Tree>) -> Ref<IdentifierNode>

  fn String(self: Ref<IdentifierNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl IfNode {
  fn Copy(self: Ref<IfNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<IfNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl ListNode {
  fn Copy(self: Ref<ListNode>) -> Node

  fn CopyList(self: Ref<ListNode>) -> Ref<ListNode>

  fn Position(self) -> Pos

  fn String(self: Ref<ListNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl NilNode {
  fn Copy(self: Ref<NilNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<NilNode>) -> string

  fn Type(self: Ref<NilNode>) -> NodeType
}

impl NodeType {
  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl NumberNode {
  fn Copy(self: Ref<NumberNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<NumberNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl PipeNode {
  fn Copy(self: Ref<PipeNode>) -> Node

  fn CopyPipe(self: Ref<PipeNode>) -> Ref<PipeNode>

  fn Position(self) -> Pos

  fn String(self: Ref<PipeNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl Pos {
  fn Position(self) -> Pos
}

impl RangeNode {
  fn Copy(self: Ref<RangeNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<RangeNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl StringNode {
  fn Copy(self: Ref<StringNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<StringNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl TemplateNode {
  fn Copy(self: Ref<TemplateNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<TemplateNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl TextNode {
  fn Copy(self: Ref<TextNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<TextNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl Tree {
  /// Copy returns a copy of the [Tree]. Any parsing state is discarded.
  fn Copy(self: Ref<Tree>) -> Ref<Tree>

  /// ErrorContext returns a textual representation of the location of the node in the input text.
  /// The receiver is only used when the node does not have a pointer to the tree inside,
  /// which can occur in old code.
  fn ErrorContext(self: Ref<Tree>, n: Node) -> (string, string)

  /// Parse parses the template definition string to construct a representation of
  /// the template for execution. If either action delimiter string is empty, the
  /// default ("{{" or "}}") is used. Embedded template definitions are added to
  /// the treeSet map.
  fn Parse(
    self: Ref<Tree>,
    text: string,
    leftDelim: string,
    rightDelim: string,
    treeSet: Map<string, Ref<Tree>>,
    funcs: VarArgs<Map<string, Unknown>>,
  ) -> Result<Ref<Tree>, error>
}

impl VariableNode {
  fn Copy(self: Ref<VariableNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<VariableNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}

impl WithNode {
  fn Copy(self: Ref<WithNode>) -> Node

  fn Position(self) -> Pos

  fn String(self: Ref<WithNode>) -> string

  /// Type returns itself and provides an easy default implementation
  /// for embedding in a Node. Embedded in all non-trivial Nodes.
  fn Type(self) -> NodeType
}
