Lines Matching full:wizard
5 require 'antlr3/tree/wizard'
17 lexer = Wizard::PatternLexer.new( '(' )
25 lexer = Wizard::PatternLexer.new(')')
33 lexer = Wizard::PatternLexer.new('%')
41 lexer = Wizard::PatternLexer.new('.')
49 lexer = Wizard::PatternLexer.new(" \n \r \t ")
57 lexer = Wizard::PatternLexer.new('__whatever_1__')
65 lexer = Wizard::PatternLexer.new('[ \]bla\n]')
73 lexer = Wizard::PatternLexer.new("1")
89 @pattern_adaptor = Wizard::PatternAdaptor.new( Tokens.token_class )
90 @wizard = Wizard.new( :adaptor => @adaptor, :token_scheme => Tokens )
95 tree = Wizard::PatternParser.parse( 'ID', Tokens, @adaptor )
103 tree = Wizard::PatternParser.parse( 'ID[foo]', Tokens, @adaptor )
111 tree = Wizard::PatternParser.parse( '(A B)', Tokens, @adaptor )
122 tree = Wizard::PatternParser.parse( 'nil', Tokens, @adaptor )
130 tree = Wizard::PatternParser.parse( '(.)', Tokens, @adaptor )
131 assert_instance_of( Wizard::WildcardPattern, tree )
135 tree = Wizard::PatternParser.parse( '(%a:A)', Tokens, @pattern_adaptor )
136 assert_instance_of(Wizard::Pattern, tree)
141 tree = Wizard::PatternParser.parse( ')', Tokens, @adaptor )
146 tree = Wizard::PatternParser.parse( '()', Tokens, @adaptor )
151 tree = Wizard::PatternParser.parse( '(A ])', Tokens, @adaptor )
164 @wizard = Wizard.new( :adaptor => @adaptor, :token_scheme => Tokens )
168 Wizard.new( :tokens => tokens )
173 @wizard = Wizard.new( :tokens => %w(A B), :adaptor => @adaptor )
175 assert_equal( @wizard.adaptor, @adaptor )
176 assert_kind_of( ANTLR3::TokenScheme, @wizard.token_scheme )
180 t = @wizard.create("ID")
185 t = @wizard.create("ID[foo]")
191 t = @wizard.create("(A)")
196 t = @wizard.create("(A B C D)")
201 t = @wizard.create("(nil A B C)")
206 t = @wizard.create("A B C")
211 t = @wizard.create("(A (B C) (B D) E)")
222 tree = @wizard.create("ID")
223 index_map = SIMPLIFY_MAP[@wizard.index(tree)]
230 tree = @wizard.create("(A B C D)")
231 index_map = SIMPLIFY_MAP[@wizard.index(tree)]
240 tree = @wizard.create("(A B (A C B) B D D)")
241 index_map = SIMPLIFY_MAP[@wizard.index(tree)]
251 tree = @wizard.create("(A B C D)")
254 @wizard.visit( tree, B ) do |node, parent, child_index, labels|
263 tree = @wizard.create("(A B (A C B) B D D)")
266 @wizard.visit( tree, C ) do |node, parent, child_index, labels|
275 tree = @wizard.create("(A B (A C B) B D D)")
278 @wizard.visit( tree, B ) do |node, parent, child_index, labels|
287 tree = @wizard.create("(A B (A C B) B D D)")
290 @wizard.visit( tree, A ) do |node, parent, child_index, labels|
302 tree = @wizard.create("(A B (A C B) B D D)")
305 @wizard.visit( tree, B ) do |node, parent, child_index, labels|
314 tree = @wizard.create("(A B (A C B) B D D)")
317 @wizard.visit( tree, A ) do |node, parent, child_index, labels|
325 tree = @wizard.create("(A B C (A B) D)")
328 @wizard.visit(tree, '(A B)') do |node, parent, child_index, labels|
337 tree = @wizard.create("(A B C (A B) (D (A B)))")
340 @wizard.visit(tree, '(A B)') do |node, parent, child_index, labels|
353 tree = @wizard.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))")
356 @wizard.visit(tree, '(%a:A %b:B)') do |node, parent, child_index, labels|
365 tree = @wizard.create("(A B C)")
366 assert @wizard.match(tree, "(A B C)")
370 tree = @wizard.create('A')
371 assert @wizard.match(tree, 'A')
375 tree = @wizard.create('A')
376 assert( !(@wizard.match(tree, 'B')) )
381 tree = @wizard.create('(nil A B C)')
382 assert @wizard.match(tree, '(nil A B C)')
386 tree = @wizard.create('(nil A B C)')
387 assert( !(@wizard.match(tree, '(nil A B)')) )
391 tree = @wizard.create('(nil A B C)')
392 assert( !(@wizard.match(tree, '(nil A B A)')) )
396 tree = @wizard.create('(A B C)')
397 assert @wizard.match(tree, '(A . .)')
401 tree = @wizard.create('(A B[foo] C[bar])')
402 assert @wizard.match(tree, '(A B[foo] C)')
406 tree = @wizard.create('(A B C)')
407 assert( !(@wizard.match(tree, '(A[foo] B C)')) )
411 tree = @wizard.create('(A B C)')
412 labels = @wizard.match( tree, '(%a:A %b:B %c:C)' )
420 tree = @wizard.create('(A B C)')
421 labels = @wizard.match(tree, '(A %b:. %c:.)')
429 tree = @wizard.create('(A B[foo] C)')
430 labels = @wizard.match( tree, '(%a:A %b:B[foo] %c:C)' )
438 tree = @wizard.create('(A (B C) (D E))')
439 labels = @wizard.match( tree, '(%a:A (%b:B %c:C) (%d:D %e:E))' )
450 tree1 = @wizard.create("(A B C)")
451 tree2 = @wizard.create("(A B C)")
452 assert @wizard.equals(tree1, tree2)
457 tree1 = @wizard.create("(A B[foo] C)")
458 tree2 = @wizard.create("(A B[foo] C)")
459 assert @wizard.equals(tree1, tree2)
464 tree1 = @wizard.create("(A B[foo] C)")
465 tree2 = @wizard.create("(A B C)")
466 assert( !(@wizard.equals(tree1, tree2)) )
471 tree1 = @wizard.create("(A B C)")
472 tree2 = @wizard.create("(A B A)")
473 assert( !(@wizard.equals(tree1, tree2)) )
477 tree1 = @wizard.create("(A B C)")
478 tree2 = @wizard.create("(A B)")
479 assert( !(@wizard.equals(tree1, tree2)) )
483 tree = @wizard.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))")
484 subtrees = @wizard.find(tree, "(A B)").map { |t| t.to_s }
489 tree = @wizard.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))")
490 subtrees = @wizard.find( tree, A ).map { |t| t.to_s }