Class: Code::Parser::Function
- Inherits:
-
Language
- Object
- Language
- Code::Parser::Function
- Defined in:
- lib/code/parser/function.rb
Instance Method Summary collapse
- #ampersand ⇒ Object
- #asterisk ⇒ Object
- #closing_curly_bracket ⇒ Object
- #closing_parenthesis ⇒ Object
- #code ⇒ Object
- #code_present ⇒ Object
- #colon ⇒ Object
- #comma ⇒ 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
- #whitespace ⇒ Object
- #whitespace? ⇒ Boolean
Instance Method Details
#ampersand ⇒ Object
62 63 64 |
# File 'lib/code/parser/function.rb', line 62 def ampersand str("&") end |
#asterisk ⇒ Object
58 59 60 |
# File 'lib/code/parser/function.rb', line 58 def asterisk str("*") end |
#closing_curly_bracket ⇒ Object
54 55 56 |
# File 'lib/code/parser/function.rb', line 54 def closing_curly_bracket str("}") end |
#closing_parenthesis ⇒ Object
30 31 32 |
# File 'lib/code/parser/function.rb', line 30 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
34 35 36 |
# File 'lib/code/parser/function.rb', line 34 def colon str(":") end |
#comma ⇒ Object
38 39 40 |
# File 'lib/code/parser/function.rb', line 38 def comma str(",") end |
#equal ⇒ Object
42 43 44 |
# File 'lib/code/parser/function.rb', line 42 def equal str("=") end |
#greater ⇒ Object
46 47 48 |
# File 'lib/code/parser/function.rb', line 46 def greater str(">") end |
#keyword_parameter ⇒ Object
71 72 73 74 |
# File 'lib/code/parser/function.rb', line 71 def keyword_parameter name.aka(:name) << whitespace? << colon.aka(:keyword) << code_present.aka(:default).maybe end |
#opening_curly_bracket ⇒ Object
50 51 52 |
# File 'lib/code/parser/function.rb', line 50 def opening_curly_bracket str("{") end |
#opening_parenthesis ⇒ Object
26 27 28 |
# File 'lib/code/parser/function.rb', line 26 def opening_parenthesis str("(") end |
#parameter ⇒ Object
81 82 83 |
# File 'lib/code/parser/function.rb', line 81 def parameter keyword_parameter | regular_parameter end |
#parameters ⇒ Object
85 86 87 88 89 |
# File 'lib/code/parser/function.rb', line 85 def parameters opening_parenthesis.ignore << whitespace? << (whitespace? << parameter << (whitespace? << comma).maybe).repeat << (whitespace? << closing_parenthesis.ignore).maybe end |
#prefix ⇒ Object
66 67 68 69 |
# File 'lib/code/parser/function.rb', line 66 def prefix (asterisk << asterisk).aka(:keyword_splat) | asterisk.aka(:regular_splat) | ampersand.aka(:block) end |
#regular_parameter ⇒ Object
76 77 78 79 |
# File 'lib/code/parser/function.rb', line 76 def regular_parameter prefix.maybe << name.aka(:name) << whitespace? << (equal << whitespace? << code_present.aka(:default)).maybe end |
#root ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/code/parser/function.rb', line 91 def root ( parameters.aka(:parameters) << whitespace? << equal << greater << whitespace? << opening_curly_bracket << code.aka(:body) << closing_curly_bracket.maybe ).aka(:function) | Dictionary 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 |