Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with simple usage #414

Closed
LGMAM opened this issue Aug 28, 2024 · 0 comments
Closed

Help with simple usage #414

LGMAM opened this issue Aug 28, 2024 · 0 comments

Comments

@LGMAM
Copy link

LGMAM commented Aug 28, 2024

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

Repository owner locked and limited conversation to collaborators Aug 28, 2024
@alecthomas alecthomas converted this issue into discussion #415 Aug 28, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant