preview

Regular Expression Of A Web App

Decent Essays

Regular Expression To FSM- Web App

3.1 Algorithm

3.1.1 Regular Expression Parsing
I built my own parser which will suit the recursive nature of my regular expression to Finite State Machine Algorithm. To parse the regular expression, first, the expression is converted from infix to prefix form. To convert from prefix to infix form, the string is read from the back and on meeting an operator, it is pushed to an operator stack if top of operator stack has lower precedence than the read operator else pop it to append to front of output string. If an operand is met, simply append it to beginning of the output string.

After converting the expression to prefix, second step is to construct expression tree where each inner node including root node has operator as its value and the leaf nodes are operands. The entire infix string is read from the end. If the character is an operand it is pushed to the operand stack else if an operator is read, operands are popped from the operand stack and assigned as left and right child of node with having the operator as the node value and pushed again into the stack. Since the backward construction algorithm is recursive in nature, such a syntax tree makes it more suitable for the algorithm where expression will be taken as input.

3.1.2 Regular Expression To FSM- Backward Construction
After converting input expression to prefix and constructing expression tree, next steps is to implement the Backward Construction algorithm for

Get Access