github.com/m3db/m3@v1.5.0/src/query/parser/m3ql/grammar.peg (about) 1 # PE Grammar for M3QL 2 # 3 # Best viewed using 140 columns monospaced with tabs every 8. 4 5 package m3ql 6 7 # Parser declaration 8 9 type m3ql Peg { 10 scriptBuilder 11 } 12 13 # Hierarchical syntax 14 15 Grammar <- Spacing (MacroDef Semicolon)* Pipeline EOF 16 17 MacroDef <- Identifier { p.newMacro(text) } Equals Pipeline 18 19 Pipeline <- { p.newPipeline() } 20 Expression (Pipe Expression)* 21 { p.endPipeline() } 22 23 Expression <- FunctionCall / Nesting 24 25 FunctionCall <- (Identifier / Operator) { p.newExpression(text) } 26 Argument* 27 { p.endExpression() } 28 29 Argument <- KeywordSpecifier? 30 ( Boolean { p.newBooleanArgument(text) } 31 / Number { p.newNumericArgument(text) } 32 / Pattern { p.newPatternArgument(text) } 33 / StringLiteral { p.newStringLiteralArgument(text) } 34 / Nesting 35 ) 36 37 KeywordSpecifier <- Identifier { p.newKeywordArgument(text) } 38 Colon 39 40 Nesting <- LParenthesis Pipeline RParenthesis 41 42 # Lexical syntax details 43 44 Spacing <- (Space / EOL / Comment)* 45 Space <- " " / "\t" 46 EOL <- "\r\n" / "\n" / "\r" 47 48 Comment <- CommentStart (!EOL .)* 49 CommentStart <- "#" 50 51 Identifier <- <IdentifierStart IdentifierChars*> Spacing 52 IdentifierStart <- [[a-z_]] 53 IdentifierChars <- IdentifierStart / [0-9] / "." / "-" / "/" / "\\" 54 55 Operator <- <OperatorSymbols> Spacing 56 OperatorSymbols <- "<=" / "<" / "==" / "!=" / ">=" / ">" 57 58 Boolean <- <(True / False)> !PatternChars Spacing 59 True <- "true" 60 False <- "false" 61 62 Number <- <Minus? (FloatingNumber / IntegralNumber)> !PatternChars Spacing 63 IntegralNumber <- [0-9]+ 64 FloatingNumber <- IntegralNumber? "." IntegralNumber 65 Minus <- "-" 66 67 StringLiteral <- QuoteChar <[^"]*> QuoteChar Spacing 68 QuoteChar <- "\"" 69 70 Pattern <- <PatternChars+> Spacing 71 PatternChars <- IdentifierChars / GlobSymbols 72 GlobSymbols <- "{" / "}" / "[" / "]" / "*" / "?" / "," / "^" / "$" 73 74 Semicolon <- ";" Spacing 75 Equals <- "=" Spacing 76 Pipe <- "|" Spacing 77 LParenthesis <- "(" Spacing 78 RParenthesis <- ")" Spacing 79 Colon <- ":" Spacing 80 81 EOF <- !.