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