Skip to content

Instantly share code, notes, and snippets.

@moreati
Last active October 11, 2021 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moreati/ff210eae529cc23e1aecedaf6286c197 to your computer and use it in GitHub Desktop.
Save moreati/ff210eae529cc23e1aecedaf6286c197 to your computer and use it in GitHub Desktop.
Approximation of the grammar for Bash braces expressions
start : brace+
brace : [preamble] expandable [postscript]
preamble : /[^{}]+/
postscript : /[^{}]+/
expandable : "{" (range | list) "}"
range : begin ".." end [".." step]
begin : BOUND
end : BOUND
step : SIGNED_INT
list : [item] ("," [item])+
item : /[^{},]+/ | brace+
BOUND : LETTER | SIGNED_INT
%import common.LETTER
%import common.SIGNED_INT
// https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html
// TODO
// Escaped "{", "}", ","
// ${}
// Unicode
@moreati
Copy link
Author

moreati commented Oct 11, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment