PageRenderTime 69ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/sh/sh.y

https://code.google.com/p/gowire/
Happy | 87 lines | 66 code | 21 blank | 0 comment | 0 complexity | b776de836a6cd3c9071fa882e76b39c9 MD5 | raw file
  1. %{
  2. %}
  3. %token IDENTIFIER FLAG COLONEQ QUOTED DOTDOTDOT FUNC ARROW
  4. %%
  5. statements: statement
  6. | statements ';' statement
  7. statement: decl
  8. | FUNC IDENTIFIER functype
  9. decl: IDENTIFIER COLONEQ pipe
  10. | pipe
  11. pipe: call
  12. | pipe '|' call
  13. call: IDENTIFIER options args
  14. options:
  15. | optionlist
  16. optionlist: option
  17. | optionlist option
  18. option: FLAG '=' expr
  19. | FLAG
  20. args:
  21. | expr
  22. | expr arglist
  23. arglist: expr
  24. | FLAG
  25. | arglist expr
  26. expr: IDENTIFIER
  27. | QUOTED
  28. | '$' IDENTIFIER
  29. | '(' options args ')'
  30. functype: flagtypes types ARROW type
  31. flagtypes: FLAG
  32. | FLAG '=' type
  33. types:
  34. | typelist
  35. typelist: type
  36. | typelist type
  37. type: IDENTIFIER
  38. %%
  39. /*
  40. func foo -g=string -quiet=bool -verbose string fd -> fd {
  41. }
  42. func walk -bs=int string -> fs {
  43. (ok f) := walk -bs=56 /usr/rog
  44. quiet ::= $ok
  45. = filter $f
  46. }
  47. FuncType = { flag "=" Type } { Type } [ "..." ] "]" } { Type } "->" Type
  48. Type = identifier
  49. Statements = Statement { ";" StatementList }
  50. Statement = Decl
  51. Decl = [ IdentifierList ":=" ] Pipe
  52. IdentifierList = identifier { "," identifier }
  53. Pipe = Call { "|" Call }
  54. Call = name Arguments
  55. Arguments = { Option } [ Expr { Expr | flag } ]
  56. Option = flag "=" Expr | flag
  57. Expr = identifier
  58. | DOTDOTDOT
  59. | string_lit
  60. | "(" Arguments ")" // XXX maybe
  61. string_lit = 'rc style string'
  62. "string with go escapes"
  63. "
  64. |string with indent
  65. "
  66. */