zomg 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. data/History.txt +6 -0
  2. data/Manifest.txt +237 -0
  3. data/README.txt +59 -0
  4. data/Rakefile +34 -0
  5. data/bin/omfg +56 -0
  6. data/lib/scanner.rex +169 -0
  7. data/lib/yacc.y +861 -0
  8. data/lib/zomg.rb +22 -0
  9. data/lib/zomg/idl.rb +14 -0
  10. data/lib/zomg/idl/lexer.rb +2151 -0
  11. data/lib/zomg/idl/nodes/attribute.rb +15 -0
  12. data/lib/zomg/idl/nodes/binary.rb +19 -0
  13. data/lib/zomg/idl/nodes/constant.rb +15 -0
  14. data/lib/zomg/idl/nodes/interface.rb +13 -0
  15. data/lib/zomg/idl/nodes/interface_header.rb +14 -0
  16. data/lib/zomg/idl/nodes/member.rb +14 -0
  17. data/lib/zomg/idl/nodes/node.rb +52 -0
  18. data/lib/zomg/idl/nodes/operation.rb +17 -0
  19. data/lib/zomg/idl/nodes/parameter.rb +18 -0
  20. data/lib/zomg/idl/nodes/typedef.rb +13 -0
  21. data/lib/zomg/idl/nodes/union.rb +14 -0
  22. data/lib/zomg/idl/parser.rb +54 -0
  23. data/lib/zomg/idl/scanner.rb +367 -0
  24. data/lib/zomg/idl/visitable.rb +15 -0
  25. data/lib/zomg/idl/visitors/duhr.rb +24 -0
  26. data/lib/zomg/idl/visitors/ruby_sexp.rb +173 -0
  27. data/lib/zomg/idl/visitors/sexp.rb +274 -0
  28. data/lib/zomg/version.rb +3 -0
  29. data/test/assets/array/array1.idl +60 -0
  30. data/test/assets/array/array2.idl +38 -0
  31. data/test/assets/array/array3.idl +8 -0
  32. data/test/assets/array/array4.idl +7 -0
  33. data/test/assets/array/array5.idl +80 -0
  34. data/test/assets/attribute/grid_0attribs_2methods.idl +16 -0
  35. data/test/assets/attribute/grid_1ROattribs_1attribs_0methods.idl +19 -0
  36. data/test/assets/attribute/grid_1ROattribs_1attribs_1methods.idl +19 -0
  37. data/test/assets/attribute/grid_1ROattribs_1attribs_2methods.idl +17 -0
  38. data/test/assets/attribute/grid_1ROattribs_1methods.idl +16 -0
  39. data/test/assets/attribute/grid_1ROattribs_2methods.idl +16 -0
  40. data/test/assets/attribute/grid_1attribs_1methods.idl +17 -0
  41. data/test/assets/attribute/grid_1attribs_2methods.idl +17 -0
  42. data/test/assets/attribute/grid_2ROattribs_0methods.idl +16 -0
  43. data/test/assets/attribute/grid_2ROattribs_1methods.idl +16 -0
  44. data/test/assets/attribute/grid_2ROattribs_2methods.idl +16 -0
  45. data/test/assets/attribute/grid_2attribs_0methods.idl +19 -0
  46. data/test/assets/attribute/grid_2attribs_1methods.idl +19 -0
  47. data/test/assets/attribute/grid_2attribs_2methods.idl +19 -0
  48. data/test/assets/comment/c_style_comments.idl +63 -0
  49. data/test/assets/comment/comment1.idl +57 -0
  50. data/test/assets/comment/cpp_style_comments.idl +168 -0
  51. data/test/assets/comment/shortform.idl +0 -0
  52. data/test/assets/complex/TestCodeSets.idl +10 -0
  53. data/test/assets/complex/TestIntfContext.idl +13 -0
  54. data/test/assets/complex/TestIntfLongLong.idl +51 -0
  55. data/test/assets/complex/TestIntfWChar.idl +52 -0
  56. data/test/assets/complex/any1.idl +22 -0
  57. data/test/assets/complex/complex1.idl +495 -0
  58. data/test/assets/complex/complex2.idl +730 -0
  59. data/test/assets/complex/complex3.idl +181 -0
  60. data/test/assets/complex/complex4.idl +181 -0
  61. data/test/assets/complex/interop_wchar.idl +60 -0
  62. data/test/assets/constant/constant1.idl +37 -0
  63. data/test/assets/constant/constant2.idl +29 -0
  64. data/test/assets/constant/constant3.idl +50 -0
  65. data/test/assets/constant/constant4.idl +21 -0
  66. data/test/assets/constant/constant5.idl +65 -0
  67. data/test/assets/constant/constant6.idl +144 -0
  68. data/test/assets/constant/constant7.idl +30 -0
  69. data/test/assets/enum/enum1.idl +13 -0
  70. data/test/assets/exception/TestIntfExceptions.idl +69 -0
  71. data/test/assets/exception/TestIntfExceptionsExt_2_0.idl +34 -0
  72. data/test/assets/exception/TestIntfExceptionsExt_2_3.idl +24 -0
  73. data/test/assets/exception/ex1.idl +6 -0
  74. data/test/assets/exception/ex2.idl +18 -0
  75. data/test/assets/exception/ex3.idl +10 -0
  76. data/test/assets/exception/ex4.idl +20 -0
  77. data/test/assets/exception/sc.idl +0 -0
  78. data/test/assets/exception/simple1.idl +18 -0
  79. data/test/assets/exception/simple2.idl +25 -0
  80. data/test/assets/factory/factory1.idl +77 -0
  81. data/test/assets/factory/objref.idl +25 -0
  82. data/test/assets/forward/forward.idl +15 -0
  83. data/test/assets/forward/forward1.idl +13 -0
  84. data/test/assets/forward/fwd_incl1.idl +6 -0
  85. data/test/assets/forward/fwd_incl2.idl +7 -0
  86. data/test/assets/include/a.idl +23 -0
  87. data/test/assets/include/b.idl +16 -0
  88. data/test/assets/include/employee.idl +12 -0
  89. data/test/assets/include/include1.idl +10 -0
  90. data/test/assets/include/include2.idl +5 -0
  91. data/test/assets/include/manager.idl +10 -0
  92. data/test/assets/include/pragma.idl +41 -0
  93. data/test/assets/include/rookie.idl +13 -0
  94. data/test/assets/include/rookiemanager.idl +15 -0
  95. data/test/assets/include/sample.idl +58 -0
  96. data/test/assets/include/sample_incl.idl +406 -0
  97. data/test/assets/inherit/IDL1.idl +18 -0
  98. data/test/assets/inherit/IDL2.idl +18 -0
  99. data/test/assets/inherit/IDL3.idl +18 -0
  100. data/test/assets/inherit/IDL4.idl +17 -0
  101. data/test/assets/inherit/diamond_inheritance.idl +31 -0
  102. data/test/assets/inherit/inherit.idl +27 -0
  103. data/test/assets/limit/longidentifiers.idl +25 -0
  104. data/test/assets/limit/namelens.idl +26 -0
  105. data/test/assets/limit/tpztest.idl +21 -0
  106. data/test/assets/module/module1.idl +29 -0
  107. data/test/assets/module/module2.idl +34 -0
  108. data/test/assets/module/module3.idl +20 -0
  109. data/test/assets/module/module4.idl +15 -0
  110. data/test/assets/nested/nested1.idl +5 -0
  111. data/test/assets/nested/nested2.idl +11 -0
  112. data/test/assets/operations/Benchmark.idl +331 -0
  113. data/test/assets/operations/CCS.idl +82 -0
  114. data/test/assets/operations/TestIntf.idl +40 -0
  115. data/test/assets/operations/TestIntfBasic.idl +653 -0
  116. data/test/assets/operations/atomic.idl +40 -0
  117. data/test/assets/operations/dif2.idl +48 -0
  118. data/test/assets/operations/interface1.idl +16 -0
  119. data/test/assets/operations/parameters.idl +111 -0
  120. data/test/assets/operations/perf.idl +84 -0
  121. data/test/assets/operations/timer.idl +104 -0
  122. data/test/assets/preprocess/base_for_diamond_inheritance_with_macros.idl +17 -0
  123. data/test/assets/preprocess/basic_macro_marshalling.idl +54 -0
  124. data/test/assets/preprocess/diamond_inheritance_with_macros.idl +74 -0
  125. data/test/assets/preprocess/macro1.idl +52 -0
  126. data/test/assets/preprocess/preprocess1.idl +246 -0
  127. data/test/assets/preprocess/preprocess2.idl +3 -0
  128. data/test/assets/recursion/loop.idl +28 -0
  129. data/test/assets/recursion/recursion1.idl +47 -0
  130. data/test/assets/recursion/recursion2.idl +74 -0
  131. data/test/assets/scenarios/filestat.idl +69 -0
  132. data/test/assets/scenarios/gateway.idl +176 -0
  133. data/test/assets/scenarios/library.idl +20 -0
  134. data/test/assets/scenarios/phone.idl +24 -0
  135. data/test/assets/scenarios/ticketservice.idl +118 -0
  136. data/test/assets/scope/scope01.idl +58 -0
  137. data/test/assets/scope/scope02.idl +25 -0
  138. data/test/assets/scope/scope03.idl +22 -0
  139. data/test/assets/scope/scope04.idl +27 -0
  140. data/test/assets/scope/scope05.idl +30 -0
  141. data/test/assets/scope/scope06.idl +51 -0
  142. data/test/assets/scope/scope07.idl +20 -0
  143. data/test/assets/scope/scope08.idl +88 -0
  144. data/test/assets/scope/scope09.idl +21 -0
  145. data/test/assets/scope/scope10.idl +95 -0
  146. data/test/assets/scope/scope11.idl +62 -0
  147. data/test/assets/scope/scope12.idl +117 -0
  148. data/test/assets/scope/scope13.idl +117 -0
  149. data/test/assets/scope/scope14.idl +117 -0
  150. data/test/assets/scope/scope15.idl +117 -0
  151. data/test/assets/scope/scope16.idl +117 -0
  152. data/test/assets/scope/scope17.idl +117 -0
  153. data/test/assets/scope/scope18.idl +117 -0
  154. data/test/assets/scope/scope19.idl +117 -0
  155. data/test/assets/scope/scope20.idl +215 -0
  156. data/test/assets/scope/scope21.idl +215 -0
  157. data/test/assets/scope/scope22.idl +205 -0
  158. data/test/assets/scope/scope23.idl +261 -0
  159. data/test/assets/scope/scope24.idl +376 -0
  160. data/test/assets/scope/scope25.idl +266 -0
  161. data/test/assets/scope/scope26.idl +180 -0
  162. data/test/assets/scope/scope27.idl +184 -0
  163. data/test/assets/scope/scope28.idl +182 -0
  164. data/test/assets/scope/scope29.idl +182 -0
  165. data/test/assets/scope/scope30.idl +40 -0
  166. data/test/assets/scope/scope31.idl +33 -0
  167. data/test/assets/scope/scope32.idl +37 -0
  168. data/test/assets/scope/scope33.idl +50 -0
  169. data/test/assets/scope/scope34.idl +97 -0
  170. data/test/assets/scope/scope35.idl +72 -0
  171. data/test/assets/scope/scope36.idl +167 -0
  172. data/test/assets/scope/scope37.idl +57 -0
  173. data/test/assets/scope/scope38.idl +38 -0
  174. data/test/assets/scope/scope39.idl +38 -0
  175. data/test/assets/scope/scope40.idl +38 -0
  176. data/test/assets/scope/scope41.idl +24 -0
  177. data/test/assets/scope/scope42.idl +64 -0
  178. data/test/assets/scope/scope43.idl +66 -0
  179. data/test/assets/scope/scope44.idl +52 -0
  180. data/test/assets/sequence/sequence1.idl +24 -0
  181. data/test/assets/sequence/sequence2.idl +9 -0
  182. data/test/assets/simple/basictypes1.idl +80 -0
  183. data/test/assets/simple/basictypes2.idl +197 -0
  184. data/test/assets/simple/basictypes3.idl +23 -0
  185. data/test/assets/simple/basictypes4.idl +73 -0
  186. data/test/assets/simple/basictypes5.idl +29 -0
  187. data/test/assets/simple/basictypes6.idl +63 -0
  188. data/test/assets/simple/simple1.idl +45 -0
  189. data/test/assets/simple/simple2.idl +61 -0
  190. data/test/assets/simple/simple3.idl +36 -0
  191. data/test/assets/string/string1.idl +11 -0
  192. data/test/assets/string/string2.idl +29 -0
  193. data/test/assets/struct/struct1.idl +20 -0
  194. data/test/assets/struct/struct2.idl +21 -0
  195. data/test/assets/struct/struct3.idl +42 -0
  196. data/test/assets/struct/struct4.idl +57 -0
  197. data/test/assets/struct/struct5.idl +71 -0
  198. data/test/assets/typecode/orb.idl +0 -0
  199. data/test/assets/typecode/pseudo.idl +25 -0
  200. data/test/assets/typedef/shorthand_typedef_struct_insideIF.idl +17 -0
  201. data/test/assets/typedef/shorthand_typedef_struct_insideIF_noMO.idl +16 -0
  202. data/test/assets/typedef/shorthand_typedef_struct_insideMO.idl +17 -0
  203. data/test/assets/typedef/shorthand_typedef_struct_outsideMO.idl +17 -0
  204. data/test/assets/typedef/typedef1.idl +8 -0
  205. data/test/assets/typedef/typedef2.idl +22 -0
  206. data/test/assets/typedef/typedef_struct_insideIF.idl +18 -0
  207. data/test/assets/typedef/typedef_struct_insideMO.idl +18 -0
  208. data/test/assets/typedef/typedef_struct_outsideMO.idl +18 -0
  209. data/test/assets/union/union1.idl +31 -0
  210. data/test/assets/union/union2.idl +22 -0
  211. data/test/assets/union/union3.idl +26 -0
  212. data/test/conversions/test_attribute.rb +30 -0
  213. data/test/conversions/test_enum.rb +25 -0
  214. data/test/conversions/test_exception.rb +24 -0
  215. data/test/conversions/test_forward_declaration.rb +22 -0
  216. data/test/conversions/test_interface.rb +30 -0
  217. data/test/conversions/test_module.rb +24 -0
  218. data/test/conversions/test_struct.rb +25 -0
  219. data/test/conversions/test_typedef.rb +22 -0
  220. data/test/conversions/test_union.rb +27 -0
  221. data/test/conversions/test_value_box_dcl.rb +22 -0
  222. data/test/helper.rb +23 -0
  223. data/test/simple/test_basictypes1.rb +87 -0
  224. data/test/simple/test_basictypes2.rb +18 -0
  225. data/test/simple/test_basictypes3.rb +32 -0
  226. data/test/simple/test_basictypes4.rb +25 -0
  227. data/test/simple/test_basictypes5.rb +17 -0
  228. data/test/simple/test_basictypes6.rb +19 -0
  229. data/test/simple/test_simple1.rb +40 -0
  230. data/test/simple/test_simple2.rb +48 -0
  231. data/test/simple/test_simple3.rb +20 -0
  232. data/test/test_array.rb +22 -0
  233. data/test/test_assets.rb +33 -0
  234. data/test/test_complex.rb +17 -0
  235. data/test/test_node.rb +15 -0
  236. data/test/test_parser.rb +17 -0
  237. data/test/test_scanner.rb +234 -0
  238. metadata +336 -0
@@ -0,0 +1,15 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Attribute < Node
5
+ alias :names :children
6
+ attr_accessor :type, :readonly
7
+ def initialize(type, names, readonly = false)
8
+ super(names)
9
+ @type = type
10
+ @readonly = readonly
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Binary < Node
5
+ attr_accessor :left
6
+ alias :right :children
7
+ def initialize(left, right)
8
+ @left = left
9
+ super(right)
10
+ end
11
+ end
12
+ %w{ MultiplyExpr PlusExpr ModulusExpr ShiftLeftExpr MinusExpr
13
+ DivideExpr OrExpr AmpersandExpr
14
+ }.each do |type|
15
+ const_set(type.to_sym, Class.new(Binary))
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Constant < Node
5
+ attr_accessor :type, :name
6
+ alias :value :children
7
+ def initialize(type, name, value)
8
+ @type = type
9
+ @name = name
10
+ super(value)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Interface < Node
5
+ attr_accessor :header
6
+ def initialize(header, body)
7
+ super(body)
8
+ @header = header
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class InterfaceHeader < Node
5
+ attr_accessor :abstract, :name
6
+ def initialize(abstract, name, inheritance_spec = [])
7
+ @abstract = abstract
8
+ @name = name
9
+ super(inheritance_spec)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Member < Node
5
+ attr_accessor :type
6
+ alias :declarators :children
7
+ def initialize(type, declarators)
8
+ @type = type
9
+ super(declarators)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,52 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Node
5
+ include Visitable
6
+ include Visitors
7
+
8
+ attr_accessor :children, :name
9
+ def initialize(children = [], options = {})
10
+ @children = children
11
+ options.each { |k,v| send(:"#{k}=", v) }
12
+ end
13
+
14
+ def to_i
15
+ children.to_i
16
+ end
17
+
18
+ def duhr
19
+ Duhr.new(self)
20
+ end
21
+
22
+ def to_sexp
23
+ Sexp.new.accept(self)
24
+ end
25
+
26
+ def to_ruby_sexp
27
+ RubySexp.new.accept(self)
28
+ end
29
+
30
+ def to_ruby(prefix = nil)
31
+ r2r = Ruby2Ruby.new
32
+ ruby_code = r2r.process(to_ruby_sexp)
33
+ if prefix
34
+ "module #{prefix}\n#{ruby_code}\nend"
35
+ else
36
+ ruby_code
37
+ end
38
+ end
39
+ end
40
+ %w{ Boolean Char Double Float Long Octet Short UnsignedLong
41
+ UnsignedShort ElementSpec CaseLabel DefaultLabel IntegerLiteral
42
+ Sequence ArraySize Void In Out InOut CharacterLiteral
43
+ UnsignedLongLong LongLong Any ForwardDeclaration WChar
44
+ FloatingPointLiteral BooleanLiteral Context StringLiteral
45
+ WideStringLiteral WideCharacterLiteral UnaryMinus Object
46
+ UnaryPlus WString String Case Enum Exception ValueBoxDcl
47
+ Struct ScopedName Module ArrayDeclarator SimpleDeclarator
48
+ Specification
49
+ }.each { |type| const_set(type.to_sym, Class.new(Node)) }
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Operation < Node
5
+ attr_accessor :attribute, :returns, :name, :raises, :context
6
+ def initialize(attribute, returns, name, params, raises, context)
7
+ super(params)
8
+ @attribute = attribute
9
+ @returns = returns
10
+ @name = name
11
+ @raises = raises
12
+ @context = context
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Parameter < Node
5
+ attr_accessor :attribute, :type, :declarator
6
+ def initialize(attribute, type, declarator)
7
+ @attribute = attribute
8
+ @type = type
9
+ @declarator = declarator
10
+ end
11
+
12
+ def name
13
+ declarator.name
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Typedef < Node
5
+ attr_accessor :type_spec
6
+ def initialize(type_spec, declarators)
7
+ @type_spec = type_spec
8
+ super(declarators)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module ZOMG
2
+ module IDL
3
+ module Nodes
4
+ class Union < Node
5
+ attr_accessor :name, :switch_type
6
+ def initialize(name, switch_type, switch_body)
7
+ @name = name
8
+ @switch_type = switch_type
9
+ super(switch_body)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,54 @@
1
+ module ZOMG
2
+ module IDL
3
+ class Parser < Lexer
4
+ class << self
5
+ def parse_file(filename)
6
+ new.parse_file(filename)
7
+ end
8
+
9
+ def parse(string)
10
+ new.parse(string)
11
+ end
12
+ end
13
+
14
+ def initialize
15
+ @scanner = Scanner.new
16
+ @yydebug = false
17
+ end
18
+
19
+ # Parse an IDL string
20
+ def parse(contents)
21
+ @scanner.scan_evaluate(contents)
22
+ do_parse
23
+ end
24
+
25
+ def parse_file(filename)
26
+ contents = File.read(filename)
27
+ if contents =~ /^\s*#/
28
+ dir = File.dirname(File.expand_path(filename))
29
+ contents = IO.popen("gcc -E -I #{dir} -I . -", 'w+') { |io|
30
+ io.write(contents)
31
+ io.close_write
32
+ io.read
33
+ }
34
+ end
35
+ parse(contents)
36
+ end
37
+
38
+ def next_token
39
+ token = @scanner.next_token
40
+ return [false, false] unless token
41
+ token = next_token() if token[0] == :T_COMMENT
42
+ token = next_token() if token[0] == :T_PREPROCESSOR
43
+ token = next_token() if token[0] == :T_PRAGMA
44
+ token
45
+ end
46
+
47
+ def on_error(error_token_id, error_value, value_stack)
48
+ puts token_to_str(error_token_id)
49
+ puts error_value
50
+ p value_stack.last
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,367 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by rex 1.0.1
4
+ # from lexical definition file "lib/scanner.rex".
5
+ #
6
+
7
+ module ZOMG
8
+ module IDL
9
+ class Scanner
10
+ require 'strscan'
11
+
12
+ class ScanError < StandardError ; end
13
+
14
+ attr_reader :lineno
15
+ attr_reader :filename
16
+
17
+ def scan_setup ; end
18
+
19
+ def action &block
20
+ yield
21
+ end
22
+
23
+ def scan_str( str )
24
+ scan_evaluate str
25
+ do_parse
26
+ end
27
+
28
+ def load_file( filename )
29
+ @filename = filename
30
+ open(filename, "r") do |f|
31
+ scan_evaluate f.read
32
+ end
33
+ end
34
+
35
+ def scan_file( filename )
36
+ load_file filename
37
+ do_parse
38
+ end
39
+
40
+ def next_token
41
+ @rex_tokens.shift
42
+ end
43
+
44
+ def scan_evaluate( str )
45
+ scan_setup
46
+ @rex_tokens = []
47
+ @lineno = 1
48
+ ss = StringScanner.new(str)
49
+ state = nil
50
+ until ss.eos?
51
+ text = ss.peek(1)
52
+ @lineno += 1 if text == "\n"
53
+ case state
54
+ when nil
55
+ case
56
+ when (text = ss.scan(/[\s\n\r]/))
57
+ ;
58
+
59
+ when (text = ss.scan(/\/\*(.|[\r\n])*?\*\//))
60
+ @rex_tokens.push action { [:T_COMMENT, text] }
61
+
62
+ when (text = ss.scan(/\/\/[^\n]*/))
63
+ @rex_tokens.push action { [:T_COMMENT, text] }
64
+
65
+ when (text = ss.scan(/\#pragma[^\n]*\n/))
66
+ @rex_tokens.push action { [:T_PRAGMA, text] }
67
+
68
+ when (text = ss.scan(/\#[^\n]*\n/))
69
+ @rex_tokens.push action { [:T_PREPROCESSOR, text] }
70
+
71
+ when (text = ss.scan(/\{/))
72
+ @rex_tokens.push action { [:T_LEFT_CURLY_BRACKET, text] }
73
+
74
+ when (text = ss.scan(/\}/))
75
+ @rex_tokens.push action { [:T_RIGHT_CURLY_BRACKET, text] }
76
+
77
+ when (text = ss.scan(/\[/))
78
+ @rex_tokens.push action { [:T_LEFT_SQUARE_BRACKET, text] }
79
+
80
+ when (text = ss.scan(/\]/))
81
+ @rex_tokens.push action { [:T_RIGHT_SQUARE_BRACKET, text] }
82
+
83
+ when (text = ss.scan(/\(/))
84
+ @rex_tokens.push action { [:T_LEFT_PARANTHESIS, text] }
85
+
86
+ when (text = ss.scan(/\)/))
87
+ @rex_tokens.push action { [:T_RIGHT_PARANTHESIS, text] }
88
+
89
+ when (text = ss.scan(/\:\:/))
90
+ @rex_tokens.push action { [:T_SCOPE, text] }
91
+
92
+ when (text = ss.scan(/:/))
93
+ @rex_tokens.push action { [:T_COLON, text] }
94
+
95
+ when (text = ss.scan(/,/))
96
+ @rex_tokens.push action { [:T_COMMA, text] }
97
+
98
+ when (text = ss.scan(/;/))
99
+ @rex_tokens.push action { [:T_SEMICOLON, text] }
100
+
101
+ when (text = ss.scan(/=/))
102
+ @rex_tokens.push action { [:T_EQUAL, text] }
103
+
104
+ when (text = ss.scan(/>>/))
105
+ @rex_tokens.push action { [:T_SHIFTRIGHT, text] }
106
+
107
+ when (text = ss.scan(/<</))
108
+ @rex_tokens.push action { [:T_SHIFTLEFT, text] }
109
+
110
+ when (text = ss.scan(/\+/))
111
+ @rex_tokens.push action { [:T_PLUS_SIGN, text] }
112
+
113
+ when (text = ss.scan(/-/))
114
+ @rex_tokens.push action { [:T_MINUS_SIGN,text] }
115
+
116
+ when (text = ss.scan(/\*/))
117
+ @rex_tokens.push action { [:T_ASTERISK, text] }
118
+
119
+ when (text = ss.scan(/\//))
120
+ @rex_tokens.push action { [:T_SOLIDUS,text] }
121
+
122
+ when (text = ss.scan(/%/))
123
+ @rex_tokens.push action { [:T_PERCENT_SIGN,text] }
124
+
125
+ when (text = ss.scan(/~/))
126
+ @rex_tokens.push action { [:T_TILDE,text] }
127
+
128
+ when (text = ss.scan(/\|/))
129
+ @rex_tokens.push action { [:T_VERTICAL_LINE,text] };
130
+
131
+ when (text = ss.scan(/\^/))
132
+ @rex_tokens.push action { [:T_CIRCUMFLEX,text] }
133
+
134
+ when (text = ss.scan(/&/))
135
+ @rex_tokens.push action { [:T_AMPERSAND,text] }
136
+
137
+ when (text = ss.scan(/</))
138
+ @rex_tokens.push action { [:T_LESS_THAN_SIGN,text] }
139
+
140
+ when (text = ss.scan(/>/))
141
+ @rex_tokens.push action { [:T_GREATER_THAN_SIGN, text] }
142
+
143
+ when (text = ss.scan(/const(?![a-zA-Z0-9_])/))
144
+ @rex_tokens.push action { [:T_CONST, text] }
145
+
146
+ when (text = ss.scan(/typedef(?![a-zA-Z0-9_])/))
147
+ @rex_tokens.push action { [:T_TYPEDEF, text] }
148
+
149
+ when (text = ss.scan(/float(?![a-zA-Z0-9_])/))
150
+ @rex_tokens.push action { [:T_FLOAT, text] }
151
+
152
+ when (text = ss.scan(/double(?![a-zA-Z0-9_])/))
153
+ @rex_tokens.push action { [:T_DOUBLE, text] }
154
+
155
+ when (text = ss.scan(/char(?![a-zA-Z0-9_])/))
156
+ @rex_tokens.push action { [:T_CHAR, text] }
157
+
158
+ when (text = ss.scan(/wchar(?![a-zA-Z0-9_])/))
159
+ @rex_tokens.push action { [:T_WCHAR, text] }
160
+
161
+ when (text = ss.scan(/fixed(?![a-zA-Z0-9_])/))
162
+ @rex_tokens.push action { [:T_FIXED, text] }
163
+
164
+ when (text = ss.scan(/boolean(?![a-zA-Z0-9_])/))
165
+ @rex_tokens.push action { [:T_BOOLEAN, text] }
166
+
167
+ when (text = ss.scan(/string(?![a-zA-Z0-9_])/))
168
+ @rex_tokens.push action { [:T_STRING, text] }
169
+
170
+ when (text = ss.scan(/wstring(?![a-zA-Z0-9_])/))
171
+ @rex_tokens.push action { [:T_WSTRING, text] }
172
+
173
+ when (text = ss.scan(/void(?![a-zA-Z0-9_])/))
174
+ @rex_tokens.push action { [:T_VOID, text] }
175
+
176
+ when (text = ss.scan(/unsigned(?![a-zA-Z0-9_])/))
177
+ @rex_tokens.push action { [:T_UNSIGNED, text] }
178
+
179
+ when (text = ss.scan(/long(?![a-zA-Z0-9_])/))
180
+ @rex_tokens.push action { [:T_LONG, text] }
181
+
182
+ when (text = ss.scan(/short(?![a-zA-Z0-9_])/))
183
+ @rex_tokens.push action { [:T_SHORT, text] }
184
+
185
+ when (text = ss.scan(/FALSE/))
186
+ @rex_tokens.push action { [:T_FALSE, text] }
187
+
188
+ when (text = ss.scan(/TRUE/))
189
+ @rex_tokens.push action { [:T_TRUE, text] }
190
+
191
+ when (text = ss.scan(/struct(?![a-zA-Z0-9_])/))
192
+ @rex_tokens.push action { [:T_STRUCT, text] }
193
+
194
+ when (text = ss.scan(/union(?![a-zA-Z0-9_])/))
195
+ @rex_tokens.push action { [:T_UNION, text] }
196
+
197
+ when (text = ss.scan(/switch(?![a-zA-Z0-9_])/))
198
+ @rex_tokens.push action { [:T_SWITCH, text] }
199
+
200
+ when (text = ss.scan(/case(?![a-zA-Z0-9_])/))
201
+ @rex_tokens.push action { [:T_CASE, text] }
202
+
203
+ when (text = ss.scan(/default(?![a-zA-Z0-9_])/))
204
+ @rex_tokens.push action { [:T_DEFAULT, text] }
205
+
206
+ when (text = ss.scan(/enum(?![a-zA-Z0-9_])/))
207
+ @rex_tokens.push action { [:T_ENUM, text] }
208
+
209
+ when (text = ss.scan(/interface(?![a-zA-Z0-9_])/))
210
+ @rex_tokens.push action { [:T_INTERFACE, text] }
211
+
212
+ when (text = ss.scan(/inout(?![a-zA-Z0-9_])/))
213
+ @rex_tokens.push action { [:T_INOUT, text] }
214
+
215
+ when (text = ss.scan(/in(?![a-zA-Z0-9_])/))
216
+ @rex_tokens.push action { [:T_IN, text] }
217
+
218
+ when (text = ss.scan(/out(?![a-zA-Z0-9_])/))
219
+ @rex_tokens.push action { [:T_OUT, text] }
220
+
221
+ when (text = ss.scan(/abstract(?![a-zA-Z0-9_])/))
222
+ @rex_tokens.push action { [:T_ABSTRACT, text] }
223
+
224
+ when (text = ss.scan(/valuetype(?![a-zA-Z0-9_])/))
225
+ @rex_tokens.push action { [:T_VALUETYPE, text] }
226
+
227
+ when (text = ss.scan(/truncatable(?![a-zA-Z0-9_])/))
228
+ @rex_tokens.push action { [:T_TRUNCATABLE, text] }
229
+
230
+ when (text = ss.scan(/supports(?![a-zA-Z0-9_])/))
231
+ @rex_tokens.push action { [:T_SUPPORTS, text] }
232
+
233
+ when (text = ss.scan(/custom(?![a-zA-Z0-9_])/))
234
+ @rex_tokens.push action { [:T_CUSTOM, text] }
235
+
236
+ when (text = ss.scan(/public(?![a-zA-Z0-9_])/))
237
+ @rex_tokens.push action { [:T_PUBLIC, text] }
238
+
239
+ when (text = ss.scan(/private(?![a-zA-Z0-9_])/))
240
+ @rex_tokens.push action { [:T_PRIVATE, text] }
241
+
242
+ when (text = ss.scan(/factory(?![a-zA-Z0-9_])/))
243
+ @rex_tokens.push action { [:T_FACTORY, text] }
244
+
245
+ when (text = ss.scan(/native(?![a-zA-Z0-9_])/))
246
+ @rex_tokens.push action { [:T_NATIVE, text] }
247
+
248
+ when (text = ss.scan(/ValueBase/))
249
+ @rex_tokens.push action { [:T_VALUEBASE, text] }
250
+
251
+ when (text = ss.scan(/module(?![a-zA-Z0-9_])/))
252
+ @rex_tokens.push action { [:T_MODULE, text] }
253
+
254
+ when (text = ss.scan(/octet(?![a-zA-Z0-9_])/))
255
+ @rex_tokens.push action { [:T_OCTET, text] }
256
+
257
+ when (text = ss.scan(/any(?![a-zA-Z0-9_])/))
258
+ @rex_tokens.push action { [:T_ANY, text] }
259
+
260
+ when (text = ss.scan(/sequence(?![a-zA-Z0-9_])/))
261
+ @rex_tokens.push action { [:T_SEQUENCE, text] }
262
+
263
+ when (text = ss.scan(/readonly(?![a-zA-Z0-9_])/))
264
+ @rex_tokens.push action { [:T_READONLY, text] }
265
+
266
+ when (text = ss.scan(/attribute(?![a-zA-Z0-9_])/))
267
+ @rex_tokens.push action { [:T_ATTRIBUTE, text] }
268
+
269
+ when (text = ss.scan(/exception(?![a-zA-Z0-9_])/))
270
+ @rex_tokens.push action { [:T_EXCEPTION, text] }
271
+
272
+ when (text = ss.scan(/oneway(?![a-zA-Z0-9_])/))
273
+ @rex_tokens.push action { [:T_ONEWAY, text] }
274
+
275
+ when (text = ss.scan(/raises(?![a-zA-Z0-9_])/))
276
+ @rex_tokens.push action { [:T_RAISES, text] }
277
+
278
+ when (text = ss.scan(/context(?![a-zA-Z0-9_])/))
279
+ @rex_tokens.push action { [:T_CONTEXT, text] }
280
+
281
+ when (text = ss.scan(/Object(?![a-zA-Z0-9_])/))
282
+ @rex_tokens.push action { [:T_OBJECT, text] }
283
+
284
+ when (text = ss.scan(/Principal/))
285
+ @rex_tokens.push action { [:T_PRINCIPAL, text] }
286
+
287
+ when (text = ss.scan(/L"(([^\n\t\"\\]|(\\[ntvbrfa\?'\\"]|\\[0-7]{1,3}|\\[xX][a-fA-F0-9]{1,2}))|')*"/))
288
+ @rex_tokens.push action { [:T_WIDE_STRING_LITERAL, text] }
289
+
290
+ when (text = ss.scan(/L'(([^\n\t\"\\]|(\\[ntvbrfa\?'\\"]|\\[0-7]{1,3}|\\[xX][a-fA-F0-9]{1,2}))|\")'/))
291
+ @rex_tokens.push action { [:T_WIDE_CHARACTER_LITERAL, text] }
292
+
293
+ when (text = ss.scan(/[a-zA-Z_][a-zA-Z0-9_]*/))
294
+ @rex_tokens.push action { [:T_IDENTIFIER, text] }
295
+
296
+ when (text = ss.scan(/[0-9]+\.[0-9]+[eE][\+-]?[0-9]+/))
297
+ @rex_tokens.push action { [:T_FLOATING_PT_LITERAL, text] }
298
+
299
+ when (text = ss.scan(/[0-9]+\.[eE][\+-]?[0-9]+/))
300
+ @rex_tokens.push action {
301
+ text = text.split('.').join('.0')
302
+ [:T_FLOATING_PT_LITERAL, text]
303
+ }
304
+
305
+
306
+ when (text = ss.scan(/[0-9]+[eE][\+-]?[0-9]+/))
307
+ @rex_tokens.push action { [:T_FLOATING_PT_LITERAL, text] }
308
+
309
+ when (text = ss.scan(/[0-9]+\.[0-9]+[dD]/))
310
+ @rex_tokens.push action { [:T_FIXED_PT_LITERAL, text.gsub(/[Dd]/,'')] }
311
+
312
+ when (text = ss.scan(/[0-9]+\.[0-9]+/))
313
+ @rex_tokens.push action { [:T_FLOATING_PT_LITERAL, text] }
314
+
315
+ when (text = ss.scan(/[0-9]+\.[dD]/))
316
+ @rex_tokens.push action { [:T_FIXED_PT_LITERAL, text.gsub(/[.dD]/,'')] }
317
+
318
+ when (text = ss.scan(/[0-9]+\./))
319
+ @rex_tokens.push action { [:T_FLOATING_PT_LITERAL, "#{text}0"] }
320
+
321
+ when (text = ss.scan(/\.[0-9]+[eE][\+-]?[0-9]+/))
322
+ @rex_tokens.push action { [:T_FLOATING_PT_LITERAL, "0#{text}"] }
323
+
324
+ when (text = ss.scan(/\.[0-9]+[dD]/))
325
+ @rex_tokens.push action {
326
+ [:T_FIXED_PT_LITERAL, "0#{text.gsub(/[dD]/, '')}"]
327
+ }
328
+
329
+
330
+ when (text = ss.scan(/\.[0-9]+/))
331
+ @rex_tokens.push action { [:T_FLOATING_PT_LITERAL, "0#{text}"] }
332
+
333
+ when (text = ss.scan(/[0-9]+[dD]/))
334
+ @rex_tokens.push action { [:T_FIXED_PT_LITERAL, text.gsub(/[dD]/,'')] }
335
+
336
+ when (text = ss.scan(/0[xX][a-fA-F0-9]*/))
337
+ @rex_tokens.push action { [:T_INTEGER_LITERAL, text] }
338
+
339
+ when (text = ss.scan(/0[0-7]*/))
340
+ @rex_tokens.push action { [:T_INTEGER_LITERAL, text] }
341
+
342
+ when (text = ss.scan(/[1-9][0-9]*/))
343
+ @rex_tokens.push action { [:T_INTEGER_LITERAL, text] }
344
+
345
+ when (text = ss.scan(/'(([^\n\t\"\\]|(\\[ntvbrfa\?'\\"]|\\[0-7]{1,3}|\\[xX][a-fA-F0-9]{1,2}))|\")'/))
346
+ @rex_tokens.push action { [:T_CHARACTER_LITERAL, text] }
347
+
348
+ when (text = ss.scan(/"(([^\n\t\"\\]|(\\[ntvbrfa\?'\\"]|\\[0-7]{1,3}|\\[xX][a-fA-F0-9]{1,2}))|')*"/))
349
+ @rex_tokens.push action { [:T_STRING_LITERAL, text] }
350
+
351
+ when (text = ss.scan(/[^\s\n\r]/))
352
+ @rex_tokens.push action { [:T_UNKNOWN, text] }
353
+
354
+ else
355
+ text = ss.string[ss.pos .. -1]
356
+ raise ScanError, "can not match: '" + text + "'"
357
+ end # if
358
+
359
+ else
360
+ raise ScanError, "undefined state: '" + state.to_s + "'"
361
+ end # case state
362
+ end # until ss
363
+ end # def scan_evaluate
364
+
365
+ end # class
366
+ end
367
+ end