myco 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap/find_constant.rb +4 -11
  3. data/lib/myco/code_loader.rb +2 -1
  4. data/lib/myco/code_tools/AST/ConstantAccess.my +47 -3
  5. data/lib/myco/code_tools/AST/ConstantAccess.my.rb +13 -9
  6. data/lib/myco/code_tools/AST/ConstantAssignment.my +1 -5
  7. data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +3 -9
  8. data/lib/myco/code_tools/AST/ToRuby.my +5 -2
  9. data/lib/myco/code_tools/AST/ToRuby.my.rb +7 -3
  10. data/lib/myco/code_tools/AST.my +1 -0
  11. data/lib/myco/code_tools/AST.my.rb +9 -1
  12. data/lib/myco/code_tools/Parser.my +24 -0
  13. data/lib/myco/code_tools/Parser.my.rb +25 -0
  14. data/lib/myco/code_tools/parser/MycoBuilder.my +67 -0
  15. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +99 -0
  16. data/lib/myco/code_tools/parser/MycoCharacterClasses.my +20 -0
  17. data/lib/myco/code_tools/parser/MycoCharacterClasses.my.rb +56 -0
  18. data/lib/myco/code_tools/parser/MycoGrammar.my +564 -0
  19. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +1851 -0
  20. data/lib/myco/code_tools/parser/MycoTokens.my +78 -0
  21. data/lib/myco/code_tools/parser/MycoTokens.my.rb +170 -0
  22. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my +4 -0
  23. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +5 -0
  24. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +142 -0
  25. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +181 -0
  26. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +420 -0
  27. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +415 -0
  28. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +137 -0
  29. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +237 -0
  30. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my +183 -0
  31. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +370 -0
  32. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +65 -0
  33. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +83 -0
  34. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my +139 -0
  35. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +284 -0
  36. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +37 -0
  37. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +24 -0
  38. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +42 -0
  39. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +52 -0
  40. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +123 -0
  41. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +164 -0
  42. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +236 -0
  43. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +339 -0
  44. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my +15 -0
  45. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +14 -0
  46. data/lib/myco/code_tools.rb +1 -1
  47. data/lib/myco/version.rb +1 -1
  48. data/lib/myco.rb +2 -0
  49. metadata +44 -25
  50. data/lib/myco/code_tools/parser/peg_parser.rb +0 -7182
  51. data/lib/myco/code_tools/parser.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c497fbe2e87f23f8cea7374510cbac8a7aefdd6a
4
- data.tar.gz: 519dc6fbe9d381ee9478ca46fa71fefecd5318b8
3
+ metadata.gz: bc8d9aa903a16793652f0a984ea68b5dc0058dee
4
+ data.tar.gz: 0ed0d4a3adb25552541a384019deeb7016d67057
5
5
  SHA512:
6
- metadata.gz: 6e7dc8c64ae6d9a26b421ba7a45dc5a0ec44f969519e128ebe680701c39d68dd70b6dde54743e99c2c5fb0b2267696c4e119095cead9c41254b1de50d28556a4
7
- data.tar.gz: 05cf18931bdf1d8632dcf9d7d88e09cc014b8af1e6a86d70f8a2b74395c8210c36d999cb25f4fc0096380618132e09887d4af23aa0130a73724055e0b7029b3d
6
+ metadata.gz: d50aa9cdf66fec631609560ea0c5bac80a39a27be523ca32ad1529795cbb0aab4cf9db3b11b55e30718e86191915c86ec95edec7ee9562d0bb687ad13f1025c3
7
+ data.tar.gz: c9ec127069f005ad5ba684b2a0fec708d7d8abceb297283838d323a14f65e0fe6df211840abf4cdbcce92db437c8b760049d2134ba30be15690c738a808d5fa5
@@ -61,27 +61,20 @@ module Myco
61
61
  Rubinius::ConstantScope.of_sender
62
62
  end
63
63
 
64
- def self.find_constant(name, scope=nil)
65
- name = ::Rubinius::Type.coerce_to_constant_name name
66
- scope ||= ::Rubinius::ConstantScope.of_sender
67
-
68
- category = scope.myco_category
69
- component = scope.myco_component
70
- file = scope.myco_file
71
-
64
+ def self.find_constant(name, scope=Rubinius::ConstantScope.of_sender)
72
65
  # TODO: optimize this constant search
73
66
  # (it currently searches each ancestor of each nested component scope)
74
67
  bucket = nil
75
68
  scope.myco_levels.detect { |level|
76
69
  bucket = find_constant_bucket_in_module(level, name)
77
70
  }
78
- bucket ? bucket.constant : ::Rubinius::Type.const_get(::Myco, name)
71
+ bucket ? bucket.constant : Rubinius::Type.const_get(::Myco, name)
79
72
  end
80
73
 
81
74
  def self.find_constant_bucket_in_module(mod, name, inherit=true)
82
- current, constant = mod, nil
75
+ current = mod
83
76
 
84
- while current and ::Rubinius::Type.object_kind_of? current, Module
77
+ while current and Rubinius::Type.object_kind_of? current, Module
85
78
  if bucket = current.constant_table.lookup(name)
86
79
  return bucket
87
80
  end
@@ -263,7 +263,8 @@ module Myco
263
263
  class RubyLoader < AbstractLoader
264
264
  def is_rb?; true end
265
265
 
266
- def emit_rb!; nil end
266
+ def emit_rb!; nil end
267
+ def emit_rbc!; nil end
267
268
 
268
269
  def initialize *args
269
270
  super *args
@@ -16,14 +16,58 @@ CodeTools::AST << {
16
16
  g.push_cpath_top
17
17
  g.find_const(first_name)
18
18
  ) ?? (
19
+ Myco.find_constant_bytecode(g, first_name)
20
+ )
21
+
22
+ name_list.each |name| { g.find_const(name) }
23
+ }
24
+
25
+ ::Myco::SingletonClass << {
26
+ find_constant_bytecode: |g, name| {
19
27
  g.push_cpath_top
20
28
  g.find_const(:"Myco")
21
- g.push_literal(first_name)
29
+ g.push_literal(name)
22
30
  g.push_scope
23
31
  g.send(:find_constant, 2)
24
- )
32
+ }
25
33
 
26
- name_list.each |name| { g.find_const(name) }
34
+ # TODO: use the try_find_const_fast instruction here, when it is merged into Rubinius.
35
+ # find_constant_bytecode: |g, name| {
36
+ # loop_start_label = g.new_label
37
+ # retry_label = g.new_label
38
+ # fail_label = g.new_label
39
+ # done_label = g.new_label
40
+
41
+ # # g.push_rubinius; g.push_literal(name); g.send(:p, 1, true); g.pop
42
+
43
+ # g.push_scope
44
+ # g.send(:myco_levels, 0)
45
+ # # TODO: don't dup, iterate without mutating
46
+ # g.send(:dup, 0) # stack: myco_levels
47
+
48
+ # loop_start_label.set!
49
+ # g.dup_top # stack: myco_levels, myco_levels
50
+ # g.send(:pop, 0) # stack: myco_levels, mod
51
+
52
+ # g.dup_top # stack: myco_levels, mod, mod
53
+ # g.goto_if_nil(fail_label) # stack: myco_levels, mod
54
+
55
+ # g.try_find_const(name) # stack: myco_levels, result
56
+ # g.dup_top # stack: myco_levels, result, result
57
+
58
+ # g.goto_if_not_undefined(done_label) # stack: myco_levels, undefined
59
+ # g.pop # stack: myco_levels
60
+ # g.goto(loop_start_label)
61
+
62
+ # fail_label.set! # stack: myco_levels, mod
63
+ # g.pop # stack: myco_levels
64
+ # g.push_cpath_top; g.find_const(:"Myco") # stack: myco_levels, ::Myco
65
+ # g.push_literal(name)
66
+ # g.send(:const_get, 1) # stack: myco_levels, result
67
+
68
+ # done_label.set! # stack: myco_levels, result
69
+ # g.swap; g.pop # stack: result
70
+ # }
27
71
  }
28
72
  }
29
73
 
@@ -16,17 +16,21 @@
16
16
  ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.toplevel) {(
17
17
  g.push_cpath_top
18
18
  g.find_const(first_name)
19
- )}) {(
20
- g.push_cpath_top
21
- g.find_const(:Myco)
22
- g.push_literal(first_name)
23
- g.push_scope
24
- g.send(
25
- :find_constant,
26
- 2
27
- )
19
+ )}) {::Myco.find_constant(:Myco).find_constant_bytecode(
20
+ g,
21
+ first_name
28
22
  )}
29
23
  name_list.each { |name| (g.find_const(name))}
30
24
  )}
25
+ ::Myco::SingletonClass.component_eval {(declare_meme(:find_constant_bytecode, [], nil, ::Myco.cscope.dup) { |g, name| (
26
+ g.push_cpath_top
27
+ g.find_const(:Myco)
28
+ g.push_literal(name)
29
+ g.push_scope
30
+ g.send(
31
+ :find_constant,
32
+ 2
33
+ )
34
+ )})}
31
35
  )}})
32
36
  .tap { |__c__| __c__.__name__ = :ConstantAccess })})}}.instance
@@ -18,11 +18,7 @@ CodeTools::AST << {
18
18
  first_name && g.find_const(first_name)
19
19
  ) ?? (
20
20
  first_name &? (
21
- g.push_cpath_top
22
- g.find_const(:"Myco")
23
- g.push_literal(first_name)
24
- g.push_scope
25
- g.send(:find_constant, 2)
21
+ Myco.find_constant_bytecode(g, first_name)
26
22
  ) ?? (
27
23
  g.push_scope
28
24
  g.send(:for_method_definition, 0)
@@ -17,15 +17,9 @@
17
17
  ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.constant.toplevel) {(
18
18
  g.push_cpath_top
19
19
  ::Myco.branch_op(:"&&", first_name) {g.find_const(first_name)}
20
- )}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", first_name) {(
21
- g.push_cpath_top
22
- g.find_const(:Myco)
23
- g.push_literal(first_name)
24
- g.push_scope
25
- g.send(
26
- :find_constant,
27
- 2
28
- )
20
+ )}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", first_name) {::Myco.find_constant(:Myco).find_constant_bytecode(
21
+ g,
22
+ first_name
29
23
  )}) {(
30
24
  g.push_scope
31
25
  g.send(
@@ -238,8 +238,11 @@ CodeTools::AST << {
238
238
  }
239
239
 
240
240
  DeclareDecorator << {
241
- to_ruby: |g|
242
- g.add("["self.name.value.inspect", "); g.add(self.arguments); g.add("]")
241
+ to_ruby: |g| {
242
+ g.add("["self.name.value.inspect", [")
243
+ g.list(self.arguments.body, ",", auto_lines:true)
244
+ g.add("]]")
245
+ }
243
246
  }
244
247
 
245
248
  BlockParameter << {
@@ -208,9 +208,13 @@
208
208
  g.add("}")
209
209
  )})})}
210
210
  ::Myco.find_constant(:DeclareDecorator).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
211
- g.add("[#{self.name.value.inspect}, ")
212
- g.add(self.arguments)
213
- g.add("]")
211
+ g.add("[#{self.name.value.inspect}, [")
212
+ g.list(
213
+ self.arguments.body,
214
+ ",",
215
+ {:auto_lines => true}
216
+ )
217
+ g.add("]]")
214
218
  )})}
215
219
  ::Myco.find_constant(:BlockParameter).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("&#{self.name}"))})}
216
220
  ::Myco.find_constant(:ParameterAssembly).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
@@ -1,6 +1,7 @@
1
1
 
2
2
  CodeTools::AST << {
3
3
  BuilderMethods: Module.new { } # TODO: move out of this file
4
+ Builder < BasicObject, BuilderMethods { }
4
5
  }
5
6
 
6
7
  import 'AST/Node.my'
@@ -1,7 +1,15 @@
1
1
 
2
2
  ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
3
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
4
- ::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition.const_set(:BuilderMethods, (::Myco.find_constant(:Module).new { || nil})))}
4
+ ::Myco.find_constant(:CodeTools)::AST.component_eval {(
5
+ ::Myco.cscope.for_method_definition.const_set(:BuilderMethods, (::Myco.find_constant(:Module).new { || nil}))
6
+ ::Myco.cscope.for_method_definition.const_set(:Builder, ::Myco::Component.new([
7
+ ::Myco.find_constant(:BasicObject),
8
+ ::Myco.find_constant(:BuilderMethods)
9
+ ], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
10
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {nil}})
11
+ .tap { |__c__| __c__.__name__ = :Builder }
12
+ )}
5
13
  declare_meme(:"AST/Node.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
14
  declare_meme(:"AST/Script.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
15
  declare_meme(:"AST/StringLiteral.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
@@ -0,0 +1,24 @@
1
+
2
+ # TODO: include Pegleromyces library in a better way than clone into subdir
3
+ import as(:"Pegleromyces") 'parser/pegleromyces/lib/pegleromyces.my'
4
+
5
+ # TODO: remove this hack
6
+ ::Myco::Pegleromyces: Pegleromyces
7
+
8
+ CodeTools::Parser < BasicObject {
9
+ MycoGrammar: Myco.eval_file('parser/MycoGrammar.my')
10
+ MycoBuilder: Myco.eval_file('parser/MycoBuilder.my')
11
+
12
+ MycoParser: Pegleromyces::BytecodeParser {
13
+ var grammar: MycoGrammar
14
+ # TODO: re-evaluate design that returns an existing builder as 'new_builder'
15
+ new_builder: MycoBuilder
16
+ }
17
+
18
+ parse_string: |string| {
19
+ parser = MycoParser
20
+ parser.parse(string)
21
+ parser.result &?
22
+ parser.result.fetch(:root) ?? parser.raise_error
23
+ }
24
+ }
@@ -0,0 +1,25 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
4
+ declare_meme(:"parser/pegleromyces/lib/pegleromyces.my", [
5
+ [:as, [:Pegleromyces]],
6
+ [:import, []]
7
+ ], nil, ::Myco.cscope.dup) { |*| nil}
8
+ ::Myco::Pegleromyces = (::Myco.find_constant(:Pegleromyces))
9
+ ::Myco.find_constant(:CodeTools)::Parser = ::Myco::Component.new([::Myco.find_constant(:BasicObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
10
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
11
+ ::Myco.cscope.for_method_definition.const_set(:MycoGrammar, (::Myco.find_constant(:Myco).eval_file("parser/MycoGrammar.my")))
12
+ ::Myco.cscope.for_method_definition.const_set(:MycoBuilder, (::Myco.find_constant(:Myco).eval_file("parser/MycoBuilder.my")))
13
+ ::Myco.cscope.for_method_definition.const_set(:MycoParser, (::Myco::Component.new([::Myco.find_constant(:Pegleromyces)::BytecodeParser], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
14
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
15
+ declare_meme(:grammar, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:MycoGrammar))}
16
+ declare_meme(:new_builder, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:MycoBuilder))}
17
+ )}}.instance))
18
+ declare_meme(:parse_string, [], nil, ::Myco.cscope.dup) { |string| (
19
+ parser = ::Myco.find_constant(:MycoParser)
20
+ parser.parse(string)
21
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", parser.result) {parser.result.fetch(:root)}) {parser.raise_error}
22
+ )}
23
+ )}}
24
+ .tap { |__c__| __c__.__name__ = :Parser }
25
+ )}}.instance
@@ -0,0 +1,67 @@
1
+
2
+ BasicObject {
3
+ # TODO: be more clever here
4
+ ASTBuilder: ::CodeTools::AST::Builder.new
5
+ var ast: ASTBuilder
6
+
7
+ var escape_encodings: {
8
+ hash = Hash.new
9
+ hash["\\a"] = 7.chr # \a 0x07 Bell or alert
10
+ hash["\\b"] = 8.chr # \b 0x08 Backspace
11
+ # TODO: # \cx Control-x
12
+ # TODO: # \C-x Control-x
13
+ hash["\\e"] = 27.chr # \e 0x1b Escape
14
+ hash["\\f"] = 12.chr # \f 0x0c Formfeed
15
+ # TODO: # \M-\C-x Meta-Control-x
16
+ hash["\\n"] = 10.chr # \n 0x0a Newline
17
+ # TODO: # \nnn Octal notation, where n is a digit
18
+ hash["\\r"] = 13.chr # \r 0x0d Carriage return
19
+ hash["\\s"] = 32.chr # \s 0x20 Space
20
+ hash["\\t"] = 9.chr # \t 0x09 Tab
21
+ hash["\\v"] = 11.chr # \v 0x0b Vertical tab
22
+ # TODO: # \xnn Hexadecimal notation, where n is a digit
23
+ hash
24
+ }
25
+
26
+ # Encode escape characters in string literals
27
+ # TODO: rigorously test and refine
28
+ encode_escapes: |str| {
29
+ str.gsub(Regexp.new("\\\\.")) |substr| {
30
+ escape_encodings.fetch(substr, substr[-1])
31
+ }
32
+ }
33
+
34
+ # Given a node,op list ([node, op, node, op, ... node]) and operator types,
35
+ # collapse the (node, op, node) groups where the operator is one of the types
36
+ #
37
+ # This function is meant to be called several times on the same list,
38
+ # with a different set of operator types each time, in order of precedence.
39
+ #
40
+ collapse: |input, *types, &block| {
41
+ output = []
42
+
43
+ # Scan through, reducing or shifting based on the operator
44
+ loop {
45
+ (input.count > 2) || break
46
+ n0 = input.shift
47
+ op = input.shift
48
+
49
+ types.include?(op.type) &? (
50
+ n1 = input.shift
51
+
52
+ result = block
53
+ &? block.call(n0,op,n1)
54
+ ?? ast.invoke(op, n0, op.sym, ast.argass(n1, [n1]))
55
+ input.unshift(result)
56
+ ) ?? (
57
+ output.push(n0)
58
+ output.push(op)
59
+ )
60
+ }
61
+
62
+ # Push the last item remaining
63
+ output.push(input.shift)
64
+
65
+ input.replace(output)
66
+ }
67
+ }
@@ -0,0 +1,99 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Component.new([::Myco.find_constant(:BasicObject)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ ::Myco.cscope.for_method_definition.const_set(:ASTBuilder, (::CodeTools::AST::Builder.new))
6
+ declare_meme(:ast, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:ASTBuilder))}
7
+ declare_meme(:escape_encodings, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (
8
+ hash = ::Myco.find_constant(:Hash).new
9
+ hash.__send__(
10
+ :[]=,
11
+ "\\a",
12
+ 7.chr
13
+ )
14
+ hash.__send__(
15
+ :[]=,
16
+ "\\b",
17
+ 8.chr
18
+ )
19
+ hash.__send__(
20
+ :[]=,
21
+ "\\e",
22
+ 27.chr
23
+ )
24
+ hash.__send__(
25
+ :[]=,
26
+ "\\f",
27
+ 12.chr
28
+ )
29
+ hash.__send__(
30
+ :[]=,
31
+ "\\n",
32
+ 10.chr
33
+ )
34
+ hash.__send__(
35
+ :[]=,
36
+ "\\r",
37
+ 13.chr
38
+ )
39
+ hash.__send__(
40
+ :[]=,
41
+ "\\s",
42
+ 32.chr
43
+ )
44
+ hash.__send__(
45
+ :[]=,
46
+ "\\t",
47
+ 9.chr
48
+ )
49
+ hash.__send__(
50
+ :[]=,
51
+ "\\v",
52
+ 11.chr
53
+ )
54
+ hash
55
+ )}
56
+ declare_meme(:encode_escapes, [], nil, ::Myco.cscope.dup) { |str| (str.gsub(::Myco.find_constant(:Regexp).new("\\\\.")) { |substr| (self.escape_encodings.fetch(
57
+ substr,
58
+ substr.__send__(
59
+ :[],
60
+ -1
61
+ )
62
+ ))})}
63
+ declare_meme(:collapse, [], nil, ::Myco.cscope.dup) { |input, *types, &block| (
64
+ output = []
65
+ self.loop { || (
66
+ ::Myco.branch_op(:"||", input.count.__send__(
67
+ :>,
68
+ 2
69
+ )) {self.__send__(:break)}
70
+ n0 = input.shift
71
+ op = input.shift
72
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", types.__send__(
73
+ :include?,
74
+ op.type
75
+ )) {(
76
+ n1 = input.shift
77
+ result = ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", block) {block.call(
78
+ n0,
79
+ op,
80
+ n1
81
+ )}) {self.ast.invoke(
82
+ op,
83
+ n0,
84
+ op.sym,
85
+ self.ast.argass(
86
+ n1,
87
+ [n1]
88
+ )
89
+ )}
90
+ input.unshift(result)
91
+ )}) {(
92
+ output.push(n0)
93
+ output.push(op)
94
+ )}
95
+ )}
96
+ output.push(input.shift)
97
+ input.replace(output)
98
+ )}
99
+ )}}.instance)}}.instance
@@ -0,0 +1,20 @@
1
+
2
+ MycoCharacterClasses: Pegleromyces::Grammar {
3
+ eol_comment: str('#') + (!eol + any).*
4
+
5
+ # TODO: reinstate the following:
6
+ nl: str("\n")
7
+ spc: set(" \t\r\f\v") / str("\\\n") / eol_comment
8
+ spc_nl: spc / nl
9
+
10
+ eof: !any
11
+ eol: nl / eof
12
+
13
+ # TODO: Unicode upper and lower
14
+ upper: range('A','Z')
15
+ lower: range('a','z') / str('_')
16
+ num: range('0','9')
17
+ alpha: lower / upper
18
+ alnum: alpha / num
19
+ suffix: str('!') / str('?')
20
+ }
@@ -0,0 +1,56 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.cscope.for_method_definition.const_set(:MycoCharacterClasses, (::Myco::Component.new([::Myco.find_constant(:Pegleromyces)::Grammar], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ declare_meme(:eol_comment, [], nil, ::Myco.cscope.dup) { |*| (self.str("#").__send__(
6
+ :+,
7
+ self.eol.__send__(:!).__send__(
8
+ :+,
9
+ self.any
10
+ ).__send__(:*)
11
+ ))}
12
+ declare_meme(:nl, [], nil, ::Myco.cscope.dup) { |*| (self.str("\n"))}
13
+ declare_meme(:spc, [], nil, ::Myco.cscope.dup) { |*| (self.set(" \t\r\f\v").__send__(
14
+ :/,
15
+ self.str("\\\n")
16
+ ).__send__(
17
+ :/,
18
+ self.eol_comment
19
+ ))}
20
+ declare_meme(:spc_nl, [], nil, ::Myco.cscope.dup) { |*| (self.spc.__send__(
21
+ :/,
22
+ self.nl
23
+ ))}
24
+ declare_meme(:eof, [], nil, ::Myco.cscope.dup) { |*| (self.any.__send__(:!))}
25
+ declare_meme(:eol, [], nil, ::Myco.cscope.dup) { |*| (self.nl.__send__(
26
+ :/,
27
+ self.eof
28
+ ))}
29
+ declare_meme(:upper, [], nil, ::Myco.cscope.dup) { |*| (self.range(
30
+ "A",
31
+ "Z"
32
+ ))}
33
+ declare_meme(:lower, [], nil, ::Myco.cscope.dup) { |*| (self.range(
34
+ "a",
35
+ "z"
36
+ ).__send__(
37
+ :/,
38
+ self.str("_")
39
+ ))}
40
+ declare_meme(:num, [], nil, ::Myco.cscope.dup) { |*| (self.range(
41
+ "0",
42
+ "9"
43
+ ))}
44
+ declare_meme(:alpha, [], nil, ::Myco.cscope.dup) { |*| (self.lower.__send__(
45
+ :/,
46
+ self.upper
47
+ ))}
48
+ declare_meme(:alnum, [], nil, ::Myco.cscope.dup) { |*| (self.alpha.__send__(
49
+ :/,
50
+ self.num
51
+ ))}
52
+ declare_meme(:suffix, [], nil, ::Myco.cscope.dup) { |*| (self.str("!").__send__(
53
+ :/,
54
+ self.str("?")
55
+ ))}
56
+ )}}.instance)))}}.instance