jq 1.7.1
1.8.2 1.8.1 1.7.1
Grammar changes
Tokens
Source: src/parser.y @ jq-1.7.1 (71c2ab5) / bison_report bison (GNU Bison) 3.8.2 / 2023-12-13
These diagrams describe a parser grammar, rather than the complete language specification. Lexer state and semantic checks may impose additional restrictions.
MIT
Start wrapper
Unreachable
BNF $accept ::= TopLevel $end
Used by (0)
References (1)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
$end
BNF TopLevel ::= Module Imports Exp
| Module Imports FuncDefs
Used by (1)
References (4)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
ε
TopLevel › Module
BNF Module ::= ε
| MODULE Exp ';'
Used by (1)
References (1)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
ε
TopLevel › Imports
BNF Imports ::= ε
| Import Imports
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
ε
TopLevel › FuncDefs
BNF FuncDefs ::= ε
| FuncDef FuncDefs
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
ε
TopLevel › Exp
BNF Exp ::= FuncDef Exp
| Term AS Patterns '|' Exp
| REDUCE Term AS Patterns '(' Exp ';' Exp ')'
| FOREACH Term AS Patterns '(' Exp ';' Exp ';' Exp ')'
| FOREACH Term AS Patterns '(' Exp ';' Exp ')'
| IF Exp THEN Exp ElseBody
| IF Exp THEN error
| TRY Exp CATCH Exp
| TRY Exp
| TRY Exp CATCH error
| LABEL BINDING '|' Exp
| Exp '?'
| Exp '=' Exp
| Exp OR Exp
| Exp AND Exp
| Exp DEFINEDOR Exp
| Exp SETDEFINEDOR Exp
| Exp SETPIPE Exp
| Exp '|' Exp
| Exp ',' Exp
| Exp '+' Exp
| Exp SETPLUS Exp
| '-' Exp
| Exp '-' Exp
| Exp SETMINUS Exp
| Exp '*' Exp
| Exp SETMULT Exp
| Exp '/' Exp
| Exp '%' Exp
| Exp SETDIV Exp
| Exp SETMOD Exp
| Exp EQ Exp
| Exp NEQ Exp
| Exp '<' Exp
| Exp '>' Exp
| Exp LESSEQ Exp
| Exp GREATEREQ Exp
| Term
Used by (11)
References (5)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
.
TopLevel › Imports › Import
BNF Import ::= ImportWhat ';'
| ImportWhat Exp ';'
Used by (1)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
include QQSTRING_START QQSTRING_END ;
TopLevel › Imports › Import › ImportWhat
BNF ImportWhat ::= IMPORT ImportFrom AS BINDING
| IMPORT ImportFrom AS IDENT
| INCLUDE ImportFrom
Used by (1)
References (1)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
include QQSTRING_START QQSTRING_END
TopLevel › Imports › Import › ImportWhat › ImportFrom
BNF ImportFrom ::= String
Used by (1)
References (1)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
QQSTRING_START QQSTRING_END
TopLevel › Exp › FuncDef
BNF FuncDef ::= DEF IDENT ':' Exp ';'
| DEF IDENT '(' Params ')' ':' Exp ';'
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
def IDENT : . ;
Code example def double: . * 2; double
TopLevel › Exp › FuncDef › Params
BNF Params ::= Param
| Params ';' Param
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › FuncDef › Params › Param
BNF Param ::= BINDING
| IDENT
Used by (1)
References (0)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Term › String › StringStart
BNF StringStart ::= FORMAT QQSTRING_START
| QQSTRING_START
Used by (1)
References (0)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
QQSTRING_START
TopLevel › Exp › Term › String
BNF String ::= StringStart QQString QQSTRING_END
Used by (4)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
QQSTRING_START QQSTRING_END
TopLevel › Exp › Term › String › QQString
BNF QQString ::= ε
| QQString QQSTRING_TEXT
| QQString QQSTRING_INTERP_START Exp QQSTRING_INTERP_END
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
ε
TopLevel › Exp › ElseBody
BNF ElseBody ::= ELSE_IF Exp THEN Exp ElseBody
| ELSE Exp END
| END
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
end
TopLevel › Exp › Term › MkDict › MkDictPair › ExpD
BNF ExpD ::= ExpD '|' ExpD
| '-' ExpD
| Term
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
.
TopLevel › Exp › Term
BNF Term ::= '.'
| REC
| BREAK BINDING
| BREAK error
| Term FIELD '?'
| FIELD '?'
| Term '.' String '?'
| '.' String '?'
| Term FIELD
| FIELD
| Term '.' String
| '.' String
| '.' error
| '.' IDENT error
| Term '[' Exp ']' '?'
| Term '[' Exp ']'
| Term '.' '[' Exp ']' '?'
| Term '.' '[' Exp ']'
| Term '[' ']' '?'
| Term '[' ']'
| Term '.' '[' ']' '?'
| Term '.' '[' ']'
| Term '[' Exp ':' Exp ']' '?'
| Term '[' Exp ':' ']' '?'
| Term '[' ':' Exp ']' '?'
| Term '[' Exp ':' Exp ']'
| Term '[' Exp ':' ']'
| Term '[' ':' Exp ']'
| LITERAL
| String
| FORMAT
| '(' Exp ')'
| '[' Exp ']'
| '[' ']'
| '{' MkDict '}'
| '$' '$' '$' BINDING
| BINDING
| LOC
| IDENT
| IDENT '(' Args ')'
| '(' error ')'
| '[' error ']'
| Term '[' error ']'
| '{' error '}'
Used by (3)
References (5)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
.
TopLevel › Exp › Term › Args
BNF Args ::= Arg
| Args ';' Arg
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
.
TopLevel › Exp › Term › Args › Arg
BNF Arg ::= Exp
Used by (1)
References (1)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
.
TopLevel › Exp › Patterns › RepPatterns
BNF RepPatterns ::= RepPatterns ALTERNATION Pattern
| Pattern
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Patterns
BNF Patterns ::= RepPatterns ALTERNATION Pattern
| Pattern
Used by (1)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Patterns › Pattern
BNF Pattern ::= BINDING
| '[' ArrayPats ']'
| '{' ObjPats '}'
Used by (4)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Patterns › Pattern › ArrayPats
BNF ArrayPats ::= Pattern
| ArrayPats ',' Pattern
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Patterns › Pattern › ObjPats
BNF ObjPats ::= ObjPat
| ObjPats ',' ObjPat
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Patterns › Pattern › ObjPats › ObjPat
BNF ObjPat ::= BINDING
| BINDING ':' Pattern
| IDENT ':' Pattern
| Keyword ':' Pattern
| String ':' Pattern
| '(' Exp ')' ':' Pattern
| error ':' Pattern
Used by (1)
References (4)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING
TopLevel › Exp › Term › MkDict › MkDictPair › Keyword
BNF Keyword ::= AS
| DEF
| MODULE
| IMPORT
| INCLUDE
| IF
| THEN
| ELSE
| ELSE_IF
| REDUCE
| FOREACH
| END
| AND
| OR
| TRY
| CATCH
| LABEL
| BREAK
Used by (2)
References (0)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
as
TopLevel › Exp › Term › MkDict
BNF MkDict ::= ε
| MkDictPair
| MkDictPair ',' MkDict
| error ',' MkDict
Used by (2)
References (2)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
ε
TopLevel › Exp › Term › MkDict › MkDictPair
BNF MkDictPair ::= IDENT ':' ExpD
| Keyword ':' ExpD
| String ':' ExpD
| String
| BINDING ':' ExpD
| BINDING
| IDENT
| LOC
| Keyword
| '(' Exp ')' ':' ExpD
| error ':' ExpD
Used by (1)
References (4)
Shortest derivation This is a token sequence derived from the grammar. It may require lexer context or semantic checks to be valid code.
BINDING