Skip to content

Dictionary doesn't seem to work properly with %whitespace #319

Open
@mingodad

Description

@mingodad

While trying one grammar I found what seems to be a bug with the combination of a dictionary for keywords and %whitespace see bellow examples and outputs, when not using %whitespace it works as expected.

Maybe I'm missing something here ?

START <-
	(ID / CREATE / DELETE)*

CREATE	<-	"create" 
DELETE	<-	"delete"

KeyWord <- (
	"create"
	| "delete"
	) !IdCharTail

IdCharTail <- [A-Za-z0-9_]

ID <- !KeyWord <[A-Za-z_] IdCharTail*>

%whitespace <- [ \t\r\n]*

Input:

I will create a deleter to delete words

Output:

+ START
  - ID (I)
  - ID (will)
  - ID (create)
  - ID (a)
  - ID (deleter)
  - ID (to)
  - ID (delete)
  - ID (words)

Expected output:

+ START
  - ID (I)
  - ID (will)
  - CREATE (create)
  - ID (a)
  - ID (deleter)
  - ID (to)
  - DELETE (delete)
  - ID (words)

If we don't use %whitespcae:

START <-
	(ID / CREATE / DELETE / _)*

CREATE	<-	"create" 
DELETE	<-	"delete"

KeyWord <- (
	"create"
	| "delete"
	) !IdCharTail

IdCharTail <- [A-Za-z0-9_]

ID <- !KeyWord <[A-Za-z_] IdCharTail*>
~_ <- [ \t\r\n]+

Output:

+ START
  - ID (I)
  - ID (will)
  - CREATE (create)
  - ID (a)
  - ID (deleter)
  - ID (to)
  - DELETE (delete)
  - ID (words)

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