Class: Code::Parser::Function
- Defined in:
- lib/code/parser/function.rb
Instance Method Summary collapse
- #ampersand ⇒ Object
- #asterisk ⇒ Object
- #begin_keyword ⇒ Object
- #body ⇒ Object
- #closing_curly_bracket ⇒ Object
- #closing_parenthesis ⇒ Object
- #code ⇒ Object
- #code_present ⇒ Object
- #colon ⇒ Object
- #comma ⇒ Object
- #do_keyword ⇒ Object
- #end_keyword ⇒ Object
- #equal ⇒ Object
- #greater ⇒ Object
- #keyword_parameter ⇒ Object
- #name ⇒ Object
- #opening_curly_bracket ⇒ Object
- #opening_parenthesis ⇒ Object
- #parameter ⇒ Object
- #parameters ⇒ Object
- #prefix ⇒ Object
- #regular_parameter ⇒ Object
- #root ⇒ Object
- #separator ⇒ Object
- #spread_operator ⇒ Object
- #whitespace ⇒ Object
- #whitespace? ⇒ Boolean
Instance Method Details
#ampersand ⇒ Object
82 83 84 |
# File 'lib/code/parser/function.rb', line 82 def ampersand str("&") end |
#asterisk ⇒ Object
78 79 80 |
# File 'lib/code/parser/function.rb', line 78 def asterisk str("*") end |
#begin_keyword ⇒ Object
34 35 36 |
# File 'lib/code/parser/function.rb', line 34 def begin_keyword str("begin") << separator.present end |
#body ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/code/parser/function.rb', line 112 def body ( (begin_keyword | do_keyword).ignore << whitespace << code << (whitespace? << end_keyword).maybe.ignore ) | ( opening_curly_bracket.ignore << whitespace? << code << (whitespace? << closing_curly_bracket).maybe.ignore ) | (code << (whitespace? << end_keyword).maybe.ignore) end |
#closing_curly_bracket ⇒ Object
74 75 76 |
# File 'lib/code/parser/function.rb', line 74 def closing_curly_bracket str("}") end |
#closing_parenthesis ⇒ Object
50 51 52 |
# File 'lib/code/parser/function.rb', line 50 def closing_parenthesis str(")") end |
#code_present ⇒ Object
14 15 16 |
# File 'lib/code/parser/function.rb', line 14 def code_present Code.new.present end |
#colon ⇒ Object
54 55 56 |
# File 'lib/code/parser/function.rb', line 54 def colon str(":") end |
#comma ⇒ Object
58 59 60 |
# File 'lib/code/parser/function.rb', line 58 def comma str(",") end |
#do_keyword ⇒ Object
30 31 32 |
# File 'lib/code/parser/function.rb', line 30 def do_keyword str("do") << separator.present end |
#end_keyword ⇒ Object
38 39 40 |
# File 'lib/code/parser/function.rb', line 38 def end_keyword str("end") << separator.present end |
#equal ⇒ Object
62 63 64 |
# File 'lib/code/parser/function.rb', line 62 def equal str("=") end |
#greater ⇒ Object
66 67 68 |
# File 'lib/code/parser/function.rb', line 66 def greater str(">") end |
#keyword_parameter ⇒ Object
92 93 94 95 |
# File 'lib/code/parser/function.rb', line 92 def keyword_parameter name.aka(:name) << whitespace? << colon.aka(:keyword) << code_present.aka(:default).maybe end |
#opening_curly_bracket ⇒ Object
70 71 72 |
# File 'lib/code/parser/function.rb', line 70 def opening_curly_bracket str("{") end |
#opening_parenthesis ⇒ Object
46 47 48 |
# File 'lib/code/parser/function.rb', line 46 def opening_parenthesis str("(") end |
#parameter ⇒ Object
102 103 104 |
# File 'lib/code/parser/function.rb', line 102 def parameter keyword_parameter | regular_parameter end |
#parameters ⇒ Object
106 107 108 109 110 |
# File 'lib/code/parser/function.rb', line 106 def parameters opening_parenthesis.ignore << whitespace? << (whitespace? << parameter << (whitespace? << comma).maybe).repeat << (whitespace? << closing_parenthesis.ignore).maybe end |
#prefix ⇒ Object
86 87 88 89 90 |
# File 'lib/code/parser/function.rb', line 86 def prefix (asterisk << asterisk).aka(:keyword_splat) | asterisk.aka(:regular_splat) | ampersand.aka(:block) | spread_operator.aka(:spread) end |
#regular_parameter ⇒ Object
97 98 99 100 |
# File 'lib/code/parser/function.rb', line 97 def regular_parameter ((prefix.maybe << name.aka(:name)) | prefix) << whitespace? << (equal << whitespace? << code_present.aka(:default)).maybe end |
#root ⇒ Object
123 124 125 126 127 128 |
# File 'lib/code/parser/function.rb', line 123 def root ( parameters.aka(:parameters) << whitespace? << equal << greater << whitespace? << body.aka(:body) ).aka(:function) | Dictionary end |
#separator ⇒ Object
26 27 28 |
# File 'lib/code/parser/function.rb', line 26 def separator Name.new.separator end |
#spread_operator ⇒ Object
42 43 44 |
# File 'lib/code/parser/function.rb', line 42 def spread_operator str("...") | str("..") | str(".") end |
#whitespace ⇒ Object
18 19 20 |
# File 'lib/code/parser/function.rb', line 18 def whitespace Whitespace end |
#whitespace? ⇒ Boolean
22 23 24 |
# File 'lib/code/parser/function.rb', line 22 def whitespace? whitespace.maybe end |