Can't parse double slash "//" #424
Answered
by
alecthomas
aimestereo
asked this question in
Q&A
-
Hello, I've took simpleexpr example as my starting point and extended it to cover all my cases. But for some reason I can't parse simple math operation: floor division: I've prepared a simplified example to highlight my exact case: Demo repo: https://github.com/aimestereo/go-dsl-floor-division-issue package main
import (
"github.com/alecthomas/participle/v2"
)
type Expr struct {
// doesn't matter if it's "/" "/" or "//"
Op string `@( "+" | "!" "=" | "&" "&" | "/" "/" | "/" )`
}
var (
parser = participle.MustBuild[Expr]()
) EBNF: Expr = ("+" | ("!" "=") | ("&" "&") | ("/" "/") | "/") . Tests that I'm checking:
|
Beta Was this translation helpful? Give feedback.
Answered by
alecthomas
Nov 3, 2024
Replies: 1 comment
-
You will need to define a custom lexer, the default lexer is the Go one which treats // as comments |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alecthomas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will need to define a custom lexer, the default lexer is the Go one which treats // as comments