sourcebot/packages/queryLanguage/src/query.grammar

102 lines
1.8 KiB
Text
Raw Permalink Normal View History

@external tokens negateToken from "./tokens" { negate }
@top Program { query }
@precedence {
negate,
and,
or @left
}
query {
OrExpr |
AndExpr |
expr
}
OrExpr { andExpr (or andExpr)+ }
AndExpr { expr expr+ }
andExpr { AndExpr | expr }
expr {
NegateExpr |
ParenExpr |
PrefixExpr |
QuotedTerm |
Term
}
NegateExpr { !negate negate (PrefixExpr | ParenExpr) }
ParenExpr { "(" query? ")" }
PrefixExpr {
ArchivedExpr |
RevisionExpr |
ContentExpr |
ContextExpr |
FileExpr |
ForkExpr |
VisibilityExpr |
RepoExpr |
LangExpr |
SymExpr |
RepoSetExpr
}
RevisionExpr { revisionKw value }
ContentExpr { contentKw value }
ContextExpr { contextKw value }
FileExpr { fileKw value }
RepoExpr { repoKw value }
LangExpr { langKw value }
SymExpr { symKw value }
RepoSetExpr { reposetKw value }
// Modifiers
ArchivedExpr { archivedKw archivedValue }
ForkExpr { forkKw forkValue }
VisibilityExpr { visibilityKw visibilityValue }
archivedValue { "yes" | "no" | "only" }
forkValue { "yes" | "no" | "only" }
visibilityValue { "public" | "private" | "any" }
QuotedTerm { quotedString }
Term { word }
value { quotedString | word }
@skip { space }
@tokens {
archivedKw { "archived:" }
revisionKw { "rev:" }
contentKw { "content:" | "c:" }
contextKw { "context:" }
fileKw { "file:" | "f:" }
forkKw { "fork:" }
visibilityKw { "visibility:" }
repoKw { "repo:" | "r:" }
langKw { "lang:" }
symKw { "sym:" }
reposetKw { "reposet:" }
or { "or" ![a-zA-Z0-9_] }
quotedString { '"' (!["\\\n] | "\\" _)* '"' }
word { (![ \t\n()]) (![ \t\n():] | ":" | "-")* }
space { $[ \t\n]+ }
@precedence {
quotedString,
archivedKw, revisionKw, contentKw, contextKw, fileKw,
forkKw, visibilityKw, repoKw, langKw,
symKw, reposetKw, or,
word
}
}