Initial Revision
[ohcount] / ext / ohcount_native / glots / html_with_php_polyglot.rb
1 require 'polyglot'
2
3 module Ohcount
4         class HtmlWithPhpPolyglot < Polyglot
5
6                 def initialize(name, html, phplanguage)
7                         @name = name
8
9                         @states = html.all_states + phplanguage.states
10                         @extra_states = []
11
12                         @transitions = html.all_transitions + phplanguage.transitions
13                         @extra_transitions = []
14
15                         # stitch phplanguage
16                         @extra_transitions << StitchTransition.new(e("<?"), :html_markup, :php_code, :to, false, name)
17                         @extra_transitions << StitchTransition.new(e("<?"), :html_comment, :php_code, :to, false, name)
18                         @extra_transitions << StitchTransition.new(e("<?"), :html_squote, :php_code, :to, false, name)
19                         @extra_transitions << StitchTransition.new(e("<?"), :html_dquote, :php_code, :to, false, name)
20                         @extra_transitions << StitchTransition.new(e("?>"), :php_code, :return, :from, false, name)
21                 end
22         end
23 end