Class org.as2lib.regexp.node.BnM

Description

BnM attempts to match a slice in the input using the Boyer-Moore string matching algorithm. The algorithm is based on the idea that the pattern can be shifted farther ahead in the search text if it is matched right to left. The pattern is compared to the input one character at a time, from the rightmost character in the pattern to the left. If the characters all match the pattern has been found. If a character does not match, the pattern is shifted right a distance that is the maximum of two functions, the bad character shift and the good suffix shift. This shift moves the attempted match position through the input more quickly than a naive one postion at a time check. The bad character shift is based on the character from the text that did not match. If the character does not appear in the pattern, the pattern can be shifted completely beyond the bad character. If the character does occur in the pattern, the pattern can be shifted to line the pattern up with the next occurrence of that character. The good suffix shift is based on the idea that some subset on the right side of the pattern has matched. When a bad character is found, the pattern can be shifted right by the pattern length if the subset does not occur again in pattern, or by the amount of distance to the next occurrence of the subset in the pattern.

Method Index

new BnM()
match(), optimize(), study()

Inherited from Node

Inherited from BasicClass

Constructor Detail

BnM

public function BnM(src:Array, lastOcc:Array, optoSft:Array, next:Node)

Method Detail

optimize

static public function optimize(node:Node):Node

match

public function match(matcher:Object, i:Number, seq:String):Boolean

Description copied from Node

This method implements the classic accept node.

Overrides

match() in org.as2lib.regexp.node.Node

study

public function study(info:TreeInfo):Boolean

Description copied from Node

This method is good for all zero length assertions.

Overrides

study() in org.as2lib.regexp.node.Node