Module: LangScan::PHP
- Defined in:
- lib/langscan/php.rb,
ext/langscan/php/php/php.c
Defined Under Namespace
Classes: Tokenizer
Constant Summary collapse
- Keywords =
%w( and or xor __FILE__ exception php_user_filter __LINE__ array as break case class const continue declare default die do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit extends for foreach function global if include include_once isset list new print require require_once return static switch unset use var while __FUNCTION__ __CLASS__ __METHOD__ final php_user_filter interface implements extends public private protected abstract clone try catch throw cfunction old_function )
- KeywordsHash =
{}
Class Method Summary collapse
- .abbrev ⇒ Object
-
.each_fragment(input) ⇒ Object
LangScan::PHP.each_fragment iterates over PHP-language fragments in input.
- .extnames ⇒ Object
- .name ⇒ Object
-
.scan(input, &block) ⇒ Object
LangScan::PHP.scan iterates over PHP program.
Class Method Details
.abbrev ⇒ Object
23 24 25 |
# File 'lib/langscan/php.rb', line 23 def abbrev "php" end |
.each_fragment(input) ⇒ Object
LangScan::PHP.each_fragment iterates over PHP-language fragments in input. The fragments contains tokens and inter-token spaces and comments.
If a String is specified, the String itself is assumed as a PHP-program. If a IO is specified, the content of the IO is assumed as a PHP-program.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/langscan/php.rb', line 42 def each_fragment(input) # :yields: token begin tokenizer = Tokenizer.new(input) while token_info = tokenizer.get_token type, text, beg_lineno, beg_columnno, beg_byteno, end_lineno, end_columnno, end_byteno = token_info token = Fragment.new(type, text, beg_lineno, beg_byteno) if (token.type == :ident or token.type == :funcall) and KeywordsHash[token.text] token.type = :keyword end yield token end ensure tokenizer.close end end |
.extnames ⇒ Object
27 28 29 |
# File 'lib/langscan/php.rb', line 27 def extnames [".php"] end |
.name ⇒ Object
19 20 21 |
# File 'lib/langscan/php.rb', line 19 def name "PHP" end |
.scan(input, &block) ⇒ Object
LangScan::PHP.scan iterates over PHP program. It yields for each Fragment.
33 34 35 |
# File 'lib/langscan/php.rb', line 33 def scan(input, &block) each_fragment(input, &block) end |