G
Georg Jaehnig
Hi,
I wonder if it's possible to have Finite State Machines (FSM) [1] in
Javascript. Basically, they must be already implemented because a
RegExp is a FSM , both describe a regular language.
But the formalism of FSMs allows much more than RegExps seem to allow.
Intersection for instance:
pattern1 = new RegExp( "(a|b|c)" ); // contains a,b,c
pattern2 = new RegExp( "(a|b)" ); // contains a,b
// This would be nice:
pattern3 = RegExp.intersect( pattern1, pattern2 )
// pattern3 = /"(a|b)"/
So do you maybe know a library with those functions? If not, is there
any way to access the internal representation of the RegExp object to
implement e.g. an intersection algorithm?
[1] http://en.wikipedia.org/wiki/Finite_state_machine
I wonder if it's possible to have Finite State Machines (FSM) [1] in
Javascript. Basically, they must be already implemented because a
RegExp is a FSM , both describe a regular language.
But the formalism of FSMs allows much more than RegExps seem to allow.
Intersection for instance:
pattern1 = new RegExp( "(a|b|c)" ); // contains a,b,c
pattern2 = new RegExp( "(a|b)" ); // contains a,b
// This would be nice:
pattern3 = RegExp.intersect( pattern1, pattern2 )
// pattern3 = /"(a|b)"/
So do you maybe know a library with those functions? If not, is there
any way to access the internal representation of the RegExp object to
implement e.g. an intersection algorithm?
[1] http://en.wikipedia.org/wiki/Finite_state_machine