pointlander / peg

Peg, Parsing Expression Grammar, is an implementation of a Packrat parser generator.
BSD 3-Clause "New" or "Revised" License
1.02k stars 121 forks source link

Bug: an error occurs when importing a repository that contains numeric character #124

Closed hachi8833 closed 3 years ago

hachi8833 commented 3 years ago

The following peg file causes an error:

parse error near PegText (line 3 symbol 9 - line 3 symbol 25): "github.com/hachi"

package grammar

import "github.com/hachi8833/sample/token"

type Parser Peg {
  token.Program
}

Program <-
    expression EOF
    / expression <.+> {p.Err(begin, buffer)} EOF
    / <.+> {p.Err(begin, buffer)} EOF

expression <-
    additive

additive <-
    multitive (
        '+' multitive {p.PushOpe("+")}
      / '-' multitive {p.PushOpe("-")}
    )*

multitive <-
    value (
        '*' value {p.PushOpe("*")}
      / '/' value {p.PushOpe("/")}
    )*

value <-
    <[0-9]+> {p.PushDigit(text)}
    / '(' expression ')'

EOF                 <- !.

Just changing the repository name to like import "github.com/hachi/sample/token" works fine. (My GitHub user name contains some numeric characters😅)

pointlander commented 3 years ago

Are you using the latest peg? Try a 'git pull' and 'go install' in your peg directory.

pointlander commented 3 years ago

See: https://github.com/pointlander/peg/blob/master/peg.peg#L32

hachi8833 commented 3 years ago

Worked well! Thank you😂

CMogilko commented 3 years ago

Can you tag repo? go install github.com/pointlander/peg downloads 2016 version if GO111MODULE=on

pointlander commented 3 years ago

tagged.