Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Potential bug with indirect left-recursion #247

Open
@LPeter1997

Description

@LPeter1997

I've isolated a 3-rule pattern, where I'd expect the parser to succeed for a given input, but it fails instead. The sample grammar:

RuleA ::= RuleB.RuleB ::= IDENTIFIER        | RuleC '.' IDENTIFIER        .RuleC ::= RuleB        | RuleA        .

The implementation:

importscala.util.parsing.combinator._importscala.util.parsing.combinator.syntactical.StandardTokenParsersobjectSimpleParserextendsStandardTokenParserswithPackratParsers {  lexical.delimiters++=List(".","$")lazyvalruleA:PackratParser[String]= ruleB<~"$"lazyvalruleB:PackratParser[String]= (ident||| ruleC~>"."~> ident)lazyvalruleC:PackratParser[String]= (ruleB||| ruleA)defmain(args:Array[String])= {    println(ruleA(newPackratReader(new lexical.Scanner("x.x$"))))  }}

It fails for inputx.x$, telling me that it expects a$ instead of the..

For me, this seems to be a problem with how indirect left-recursion is handled. I'm not sure if theoriginal algorithm is incapable of handling this pattern, or this is an implementation bug.

Edit:
I've accidentally used| (first matching alt.) instead of||| (longest matching alt.), I've fixed that in the code, but doesn't change the outcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp