class Knj::Php_parser
Attributes
cont[R]
retcont[R]
Public Class Methods
new(args)
click to toggle source
# File lib/knj/php_parser/php_parser.rb, line 4 def initialize(args) @args = args @cont = File.read(@args["file"]) if !args.key?("require_requirements") or args["require_requirements"] @retcont = "require \"knj/autoload\"\n" @retcont << "require \"php4r\"\n" @retcont << "require \"knj/php_parser/php_parser\"\n" @retcont << "\n" else @retcont = "" end end
Public Instance Methods
args()
click to toggle source
# File lib/knj/php_parser/arguments.rb, line 2 def args end
func_args(func_name)
click to toggle source
# File lib/knj/php_parser/functions.rb, line 2 def func_args(func_name) func_arg_count = 0 args = [] loop do if match = self.matchclear(/\A\$#{@regex_varname}\s*(,\s*|)/) args << { "varname" => match[1], "newname" => "phpvar_#{match[1]}" } elsif match = self.matchclear(/\A\)\s*\{/) break else raise "Could not match function arguments." end end @retcont << "#{self.tabs}module Knj::Php_parser::Functions\n" @tabs << 1 @retcont << "#{self.tabs}def self.#{func_name}(" first = true args.each do |arg| @retcont << ", " if !first first = false if first @retcont << arg["newname"] end @retcont << ")\n" @tabs += 1 @funcs_started += 1 self.search_newstuff end
func_args_given()
click to toggle source
# File lib/knj/php_parser/functions.rb, line 61 def func_args_given arg_found = false loop do if !arg_found and match = self.matchclear(/\A\"/) @retcont << "\"" self.match_semi @retcont << ")" arg_found = true elsif !arg_found and match = self.matchclear(/\A\$(#{@regex_varname})/) @retcont << "phpvar_#{match[1]}" arg_found = true elsif arg_found and match = self.matchclear(/\A\.\s*/) @retcont << " + " arg_found = false elsif arg_found and match = self.matchclear(/\A\)\s*;/) @retcont << "\n" break else raise "Could not figure out what to do." end end end
func_args_single_given()
click to toggle source
# File lib/knj/php_parser/functions.rb, line 37 def func_args_single_given arg_found = false loop do if !arg_found and match = self.matchclear(/\A\"/) @retcont << "\"" self.match_semi @retcont << ")" arg_found = true elsif !arg_found and match = self.matchclear(/\A\$(#{@regex_varname})/) @retcont << "phpvar_#{match[1]}" arg_found = true elsif arg_found and match = self.matchclear(/\A\.\s*/) @retcont << " + " arg_found = false elsif arg_found and match = self.matchclear(/\A;/) @retcont << "\n" break else raise "Could not figure out what to do." end end end
match_semi()
click to toggle source
# File lib/knj/php_parser/functions.rb, line 85 def match_semi loop do if match = self.matchclear(/\A[A-z\d_\.]+/) @retcont << match[0] elsif match = self.matchclear(/\A\"/) @retcont << "\"" break else raise "Could not figure out what to do." end end end