Skip to content

Help with simple usage #414

@LGMAM

Description

@LGMAM

Hi all,

Just starting to use this library to parse a custom file format, quite similiar to INI files.

I am not able to get right the most simple example.

This is the file contents

==abc
zzz

And this is the parser

var lexerDefinition = lexer.MustSimple([]lexer.SimpleRule{
	{Name: "Ident", Pattern: `[a-zA-Z][a-zA-Z_\d]*`},
})

var Parser = participle.MustBuild[Matadown](
	participle.Lexer(lexerDefinition),
)

type Matadown struct {
	Sections []*Section `@@*`
}

type Section struct {
	Title   string   `"==" @Ident`
	Content *Content `@@`
}

type Content struct {
	String string `@Ident`
}

Getting this error

1:1: invalid input text "==abc\nzzz\n\n"

Any hint ?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions