International Journal of Reconfigurable Computing / 2009 / Article / Alg 1

Research Article

Software Toolchain for Large-Scale RE-NFA Construction on FPGA

Algorithm 1

Modified McNaughton-Yamada construction (MMY) converting a regular expression parse-tree to an RE-NFA with a modular and uniform structure.
Notations:
[value]Content value of node .
[leftrightchild] Left, right, or only child of node .
[next]    Set of next-state transitions of state .
[char]     Set of matching characters of state .
Macros:
CREATE_STATE ( ):
      Create a new state in the state transition table
      
CREATE_PSEAUDO():
Create a special pseudo-state for later use.
ADD_PSEUDO_NEXT ( ):
For every state , add the state set [next]
to [next]. Pseudo-state is deleted afterward.
PROCEDURE RE2NFA ( , , )
Root node of the parse (sub-)tree.
  Set of immediate previous states.
  Set of states transitioning directly outside of .
The resulting state transition table.
BEGIN
;
while
if [value] = OP_CONCAT
RE2NFA ( [left], );
[right];
else if  [value] = OP_UNION
RE2NFA ( [left],
RE2NFA ( [right],
return ;
else if  [value] = OP_CLOSURE
CREATE_PSEUO();
;
RE2NFA ( [child], ;
ADD_PSEUDO_NEXT ;
return   ;
else //
CREATE_STATE
[char] [value];
foreach   in
// add -transitions
[next] [next]
end foreach
return ;
end if
end while
// error: [right] cannot be
END

Article of the Year Award: Outstanding research contributions of 2020, as selected by our Chief Editors. Read the winning articles.