Initial Revision
[ohcount] / ext / ohcount_native / glots / line_comment_monoglot.rb
1 require 'monoglot'
2
3 module Ohcount
4         class LineCommentMonoglot < Monoglot
5
6                 def initialize(language, line_comment_tokens)
7                         @name = language
8
9                         @states = [
10                                 State.new(language, :code, :code),
11                                 State.new(language, :comment, :comment)
12                         ]
13
14                         @transitions = []
15                         [ line_comment_tokens ].flatten.each_with_index do |token, index|
16                                 @transitions << Transition.new(language, token, :code, :comment, :to, false, index.to_s)
17                         end
18                         @transitions << Transition.new(language, '\n', :comment, :return, :from, false)
19                 end
20         end
21 end