justfile 语法

Justfiles 由温和的上下文敏感的标记化器,和深度(往下)递归解析器,处理。语法主要是 LL(1), 尽管多了个额外的前瞻标记,它用于区分,导出任务和带参数配方的。

这里,中文会不太清晰,还是看english

标记(token)

  1. BACKTICK = `[^`\n\r]*`
  2. COMMENT = #([^!].*)?$
  3. DEDENT = emitted when indentation decreases
  4. EOF = emitted at the end of the file
  5. INDENT = emitted when indentation increases
  6. LINE = emitted before a recipe line
  7. NAME = [a-zA-Z_][a-zA-Z0-9_-]*
  8. NEWLINE = \n|\r\n
  9. RAW_STRING = '[^'\r\n]*'
  10. STRING = "[^"]*" # also processes \n \r \t \" \\ escapes
  11. TEXT = recipe text, only matches in a recipe body

语言句法(grammar syntax)

  1. | alternation
  2. () grouping
  3. _? option (0 or 1 times)
  4. _* repetition (0 or more times)
  5. _+ repetition (1 or more times)

语法

  1. justfile : item* EOF
  2. item : recipe
  3. | assignment
  4. | export
  5. | eol
  6. eol : NEWLINE
  7. | COMMENT NEWLINE
  8. assignment : NAME '=' expression eol
  9. export : 'export' assignment
  10. expression : value '+' expression
  11. | value
  12. value : NAME '(' arguments? ')'
  13. | STRING
  14. | RAW_STRING
  15. | BACKTICK
  16. | NAME
  17. arguments : expression ',' arguments
  18. | expression ','?
  19. recipe : '@'? NAME parameter* ('+' parameter)? ':' dependencies? body?
  20. parameter : NAME
  21. | NAME '=' STRING
  22. | NAME '=' RAW_STRING
  23. dependencies : NAME+
  24. body : INDENT line+ DEDENT
  25. line : LINE (TEXT | interpolation)+ NEWLINE
  26. | NEWLINE
  27. interpolation : '{{' expression '}}'