#-- # DO NOT MODIFY!!!! # This file is automatically generated by rex 1.0.4 # from lexical definition file "lib/build-tool/cfg/lexer.rex". #++ require 'racc/parser' # vim:ft=ruby # ### HEADER # require 'build-tool/cfg/lexer_base.rb' module BuildTool::Cfg class Lexer < Racc::Parser require 'strscan' class ScanError < StandardError ; end attr_reader :lineno attr_reader :filename attr_accessor :state def scan_setup(str) @ss = StringScanner.new(str) @lineno = 1 @state = nil end def action(&block) yield end def scan_str(str) scan_setup(str) do_parse end def load_file( filename ) @filename = filename open(filename, "r") do |f| scan_setup(f.read) end end def scan_file( filename ) load_file(filename) do_parse end def next_token return if @ss.eos? text = @ss.peek(1) @lineno += 1 if text == "\n" token = case @state when nil case when (text = @ss.scan(/log-directory\b/)) action { [ :LOG_DIRECTORY, text ]; } when (text = @ss.scan(/include\b/)) action { [ :INCLUDE, text ]; } when (text = @ss.scan(/feature\b/)) action { [ :FEATURE, text ]; } when (text = @ss.scan(/long\b/)) action { [ :LONG, text ]; } when (text = @ss.scan(/short\b/)) action { [ :SHORT, text ]; } when (text = @ss.scan(/description\b/)) action { [ :DESCRIPTION, text ]; } when (text = @ss.scan(/end\b/)) action { [ :END, text ]; } when (text = @ss.scan(/enable\b/)) action { @states.push @state; @state = :ENABLE; [:ENABLE, text]; } when (text = @ss.scan(/disable\b/)) action { @states.push @state; @state = :DISABLE; [:DISABLE, text]; } when (text = @ss.scan(/vcs\b/)) action { @states.push @state; @state = :VCS; [:VCS, text]; } when (text = @ss.scan(/build-system\b/)) action { @states.push @state; @state = :BUILD_SYSTEM; [:BUILD_SYSTEM, text]; } when (text = @ss.scan(/server\b/)) action { @states.push @state; @state = :SERVER; [:SERVER, text]; } when (text = @ss.scan(/environment\b/)) action { @states.push @state; @state = :ENVIRONMENT; [:ENVIRONMENT, text]; } when (text = @ss.scan(/module\b/)) action { @states.push @state; @state = :MODULE; [:MODULE, text]; } when (text = @ss.scan(/repository\b/)) action { @states.push @state; @state = :REPOSITORY; [:REPOSITORY, text]; } when (text = @ss.scan(/ssh-key\b/)) action { @states.push @state; @state = :SSH_KEY; [:SSH_KEY, text]; } when (text = @ss.scan(/"([^\"\r\n]*)"/)) action { [:STRING, @ss[1]]; } when (text = @ss.scan(/[a-zA-Z][A-Za-z_0-9-]*/)) action { [:TOKEN, text]; } when (text = @ss.scan(/\#[^\r\n]*/)) action { [:COMMENT, text]; } when (text = @ss.scan(/[ \t]+/)) action { [:IGNORE, text]; } when (text = @ss.scan(/[\r\n]/)) action { [:IGNORE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)$/)) action { [:GARBAGE, text]; } when (text = @ss.scan(/./)) action { [:GARBAGE, text]; } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if when :ARCHIVE case when (text = @ss.scan(/end\b/)) action { @state = @states.pop; [ :END, text ]; } when (text = @ss.scan(/"([^\"\r\n]*)"/)) action { [:STRING, @ss[1]]; } when (text = @ss.scan(/[a-zA-Z][A-Za-z_0-9-]*/)) action { [:TOKEN, text]; } when (text = @ss.scan(/\#[^\r\n]*/)) action { [:COMMENT, text]; } when (text = @ss.scan(/[ \t]+/)) action { [:IGNORE, text]; } when (text = @ss.scan(/[\r\n]/)) action { [:IGNORE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)$/)) action { [:GARBAGE, text]; } when (text = @ss.scan(/./)) action { [:GARBAGE, text]; } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if when :BUILD_SYSTEM case when (text = @ss.scan(/option/)) action { [:OPTION, text]; } when (text = @ss.scan(/inplace/)) action { [:INPLACE, text]; } when (text = @ss.scan(/end\b/)) action { @state = @states.pop; [ :END, text ]; } when (text = @ss.scan(/"([^\"\r\n]*)"/)) action { [:STRING, @ss[1]]; } when (text = @ss.scan(/[a-zA-Z][A-Za-z_0-9-]*/)) action { [:TOKEN, text]; } when (text = @ss.scan(/\#[^\r\n]*/)) action { [:COMMENT, text]; } when (text = @ss.scan(/[ \t]+/)) action { [:IGNORE, text]; } when (text = @ss.scan(/[\r\n]/)) action { [:IGNORE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)$/)) action { [:GARBAGE, text]; } when (text = @ss.scan(/./)) action { [:GARBAGE, text]; } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if when :DISABLE case when (text = @ss.scan(/feature\b/)) action { @state = @states.pop; [:FEATURE, text]; } when (text = @ss.scan(/module\b/)) action { @state = @states.pop; [:MODULE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)"/)) action { [:STRING, @ss[1]]; } when (text = @ss.scan(/[a-zA-Z][A-Za-z_0-9-]*/)) action { [:TOKEN, text]; } when (text = @ss.scan(/\#[^\r\n]*/)) action { [:COMMENT, text]; } when (text = @ss.scan(/[ \t]+/)) action { [:IGNORE, text]; } when (text = @ss.scan(/[\r\n]/)) action { [:IGNORE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)$/)) action { [:GARBAGE, text]; } when (text = @ss.scan(/./)) action { [:GARBAGE, text]; } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if when :ENABLE case when (text = @ss.scan(/feature\b/)) action { @state = @states.pop; [:FEATURE, text]; } when (text = @ss.scan(/module\b/)) action { @state = @states.pop; [:MODULE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)"/)) action { [:STRING, @ss[1]]; } when (text = @ss.scan(/[a-zA-Z][A-Za-z_0-9-]*/)) action { [:TOKEN, text]; } when (text = @ss.scan(/\#[^\r\n]*/)) action { [:COMMENT, text]; } when (text = @ss.scan(/[ \t]+/)) action { [:IGNORE, text]; } when (text = @ss.scan(/[\r\n]/)) action { [:IGNORE, text]; } when (text = @ss.scan(/"([^\"\r\n]*)$/)) action { [:GARBAGE, text]; } when (text = @ss.scan(/./)) action { [:GARBAGE, text]; } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if when :ENVIRONMENT case when (text = @ss.scan(/var\b/)) action { [:VAR, text] } when (text = @ss.scan(/prepend\b/)) action { [:PREPEND, text] } when (text = @ss.scan(/append\b/)) action { [:APPEND, text] } when (text = @ss.scan(/set\b/)) action { [:SET, text] } when (text = @ss.scan(/