TheAlgorithms-C/dd/d2e/mcnaughton__yamada__thompson_8c.html
2023-04-27 19:43:13 +00:00

1616 lines
162 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C: misc/mcnaughton_yamada_thompson.c File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Algorithms_in_C<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('dd/d2e/mcnaughton__yamada__thompson_8c.html','../../'); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">mcnaughton_yamada_thompson.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<p><a href="https://en.wikipedia.org/wiki/Thompson%27s_construction" target="_blank">McNaughtonYamadaThompson algorithm</a>
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;assert.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for mcnaughton_yamada_thompson.c:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d2/d24/mcnaughton__yamada__thompson_8c__incl.svg" width="339" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">for assert() <a href="../../d8/d66/struct_a_s_t_node.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Definition for a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state transition rule. <a href="../../d9/dd9/structtrans_rule.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Definition for a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state. <a href="../../d4/d97/struct_n_f_a_state.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Definition for the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> itself. <a href="../../d3/dd7/struct_n_f_a.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a12df013d848665fdcdcb01870c322af6"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a12df013d848665fdcdcb01870c322af6">createNode</a> (const char content)</td></tr>
<tr class="memdesc:a12df013d848665fdcdcb01870c322af6"><td class="mdescLeft">&#160;</td><td class="mdescRight">creates and initializes a AST node <br /></td></tr>
<tr class="separator:a12df013d848665fdcdcb01870c322af6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6a97ab2db6392f262b03370689872348"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6a97ab2db6392f262b03370689872348">destroyNode</a> (struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> *<a class="el" href="../../d5/da1/structnode.html">node</a>)</td></tr>
<tr class="memdesc:a6a97ab2db6392f262b03370689872348"><td class="mdescLeft">&#160;</td><td class="mdescRight">recursively destroys a AST <br /></td></tr>
<tr class="separator:a6a97ab2db6392f262b03370689872348"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae9a5eac7c0d8ac478eb1b97529638fb6"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ae9a5eac7c0d8ac478eb1b97529638fb6">preProcessing</a> (const char *input)</td></tr>
<tr class="memdesc:ae9a5eac7c0d8ac478eb1b97529638fb6"><td class="mdescLeft">&#160;</td><td class="mdescRight">performs preprocessing on a regex string, making all implicit concatenations explicit <br /></td></tr>
<tr class="separator:ae9a5eac7c0d8ac478eb1b97529638fb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a496e9b4e45417ac56dac40bbbb769d7a"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a> (const char *input)</td></tr>
<tr class="memdesc:a496e9b4e45417ac56dac40bbbb769d7a"><td class="mdescLeft">&#160;</td><td class="mdescRight">recursively constructs a AST from a preprocessed regex string <br /></td></tr>
<tr class="separator:a496e9b4e45417ac56dac40bbbb769d7a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0b8d037bf2841dede90be41f5fe1ccdc"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a> (struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *state, char c)</td></tr>
<tr class="memdesc:a0b8d037bf2841dede90be41f5fe1ccdc"><td class="mdescLeft">&#160;</td><td class="mdescRight">creates and initializes a transition rule <br /></td></tr>
<tr class="separator:a0b8d037bf2841dede90be41f5fe1ccdc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ade1398311f666988b895f41c3e36d70e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ade1398311f666988b895f41c3e36d70e">destroyRule</a> (struct <a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a> *rule)</td></tr>
<tr class="memdesc:ade1398311f666988b895f41c3e36d70e"><td class="mdescLeft">&#160;</td><td class="mdescRight">destroys a transition rule object <br /></td></tr>
<tr class="separator:ade1398311f666988b895f41c3e36d70e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa87c20bf2b324829943accce4bbff84a"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aa87c20bf2b324829943accce4bbff84a">createState</a> (void)</td></tr>
<tr class="memdesc:aa87c20bf2b324829943accce4bbff84a"><td class="mdescLeft">&#160;</td><td class="mdescRight">creates and initializes a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state <br /></td></tr>
<tr class="separator:aa87c20bf2b324829943accce4bbff84a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9a361f55b51ce6d677e907396fbc1652"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a9a361f55b51ce6d677e907396fbc1652">destroyState</a> (struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *state)</td></tr>
<tr class="memdesc:a9a361f55b51ce6d677e907396fbc1652"><td class="mdescLeft">&#160;</td><td class="mdescRight">destroys a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state <br /></td></tr>
<tr class="separator:a9a361f55b51ce6d677e907396fbc1652"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2491d4e9e630ebb9880260379779cf63"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a2491d4e9e630ebb9880260379779cf63">createNFA</a> (void)</td></tr>
<tr class="memdesc:a2491d4e9e630ebb9880260379779cf63"><td class="mdescLeft">&#160;</td><td class="mdescRight">creates and initializes a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> <br /></td></tr>
<tr class="separator:a2491d4e9e630ebb9880260379779cf63"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a684ed3494e22ee17d7b3e19a4d1fe977"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a684ed3494e22ee17d7b3e19a4d1fe977">destroyNFA</a> (struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa)</td></tr>
<tr class="memdesc:a684ed3494e22ee17d7b3e19a4d1fe977"><td class="mdescLeft">&#160;</td><td class="mdescRight">recursively destroys a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> <br /></td></tr>
<tr class="separator:a684ed3494e22ee17d7b3e19a4d1fe977"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a799974b5bc43a844a200715db21b1124"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a799974b5bc43a844a200715db21b1124">addState</a> (struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa, struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *state)</td></tr>
<tr class="memdesc:a799974b5bc43a844a200715db21b1124"><td class="mdescLeft">&#160;</td><td class="mdescRight">adds a state to a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> <br /></td></tr>
<tr class="separator:a799974b5bc43a844a200715db21b1124"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4ed0049e15d45e0d75a991fbb6f8963c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a> (struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa, struct <a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a> *rule, int loc)</td></tr>
<tr class="memdesc:a4ed0049e15d45e0d75a991fbb6f8963c"><td class="mdescLeft">&#160;</td><td class="mdescRight">adds a transition rule to a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> <br /></td></tr>
<tr class="separator:a4ed0049e15d45e0d75a991fbb6f8963c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a86e0f235783b005e4e6e951c9603bbe1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a86e0f235783b005e4e6e951c9603bbe1">postProcessing</a> (struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa)</td></tr>
<tr class="memdesc:a86e0f235783b005e4e6e951c9603bbe1"><td class="mdescLeft">&#160;</td><td class="mdescRight">performs postprocessing on a compiled <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a>, add circular empty character transition rules where it's needed for the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> to function correctly <br /></td></tr>
<tr class="separator:a86e0f235783b005e4e6e951c9603bbe1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aebe16fbf12c8ac089501ebcae6f0c050"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aebe16fbf12c8ac089501ebcae6f0c050">transit</a> (struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa, char input)</td></tr>
<tr class="memdesc:aebe16fbf12c8ac089501ebcae6f0c050"><td class="mdescLeft">&#160;</td><td class="mdescRight">moves a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> forward <br /></td></tr>
<tr class="separator:aebe16fbf12c8ac089501ebcae6f0c050"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2dabcd5c410a4b0cac1b4ab378c9dcdc"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a2dabcd5c410a4b0cac1b4ab378c9dcdc">isAccepting</a> (const struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa)</td></tr>
<tr class="memdesc:a2dabcd5c410a4b0cac1b4ab378c9dcdc"><td class="mdescLeft">&#160;</td><td class="mdescRight">determines whether the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> is currently in its accepting state <br /></td></tr>
<tr class="separator:a2dabcd5c410a4b0cac1b4ab378c9dcdc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6eaf52853f2b39a1299cc16972a3298e"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a> (const char ch)</td></tr>
<tr class="memdesc:a6eaf52853f2b39a1299cc16972a3298e"><td class="mdescLeft">&#160;</td><td class="mdescRight">helper function to determine whether a character should be considered a character literal <br /></td></tr>
<tr class="separator:a6eaf52853f2b39a1299cc16972a3298e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aab463320a19667bd604db2405abefd55"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aab463320a19667bd604db2405abefd55">indexOf</a> (const char *str, char key)</td></tr>
<tr class="memdesc:aab463320a19667bd604db2405abefd55"><td class="mdescLeft">&#160;</td><td class="mdescRight">utility function to locate the first occurrence of a character in a string while respecting parentheses <br /></td></tr>
<tr class="separator:aab463320a19667bd604db2405abefd55"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a072d13f905ab9438d38d7415df222817"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a> (const char *str, size_t <a class="el" href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a>, size_t end)</td></tr>
<tr class="memdesc:a072d13f905ab9438d38d7415df222817"><td class="mdescLeft">&#160;</td><td class="mdescRight">utility function to create a subString <br /></td></tr>
<tr class="separator:a072d13f905ab9438d38d7415df222817"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af1fbbb13a173dbacb0d4195923ab6cb3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#af1fbbb13a173dbacb0d4195923ab6cb3">redirect</a> (struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *nfa, struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *src, struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *dest)</td></tr>
<tr class="memdesc:af1fbbb13a173dbacb0d4195923ab6cb3"><td class="mdescLeft">&#160;</td><td class="mdescRight">helper function to recursively redirect transition rule targets <br /></td></tr>
<tr class="separator:af1fbbb13a173dbacb0d4195923ab6cb3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac3ded2c86cae5d238511a1e2d8bf7a80"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ac3ded2c86cae5d238511a1e2d8bf7a80">compileFromAST</a> (struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> *root)</td></tr>
<tr class="separator:ac3ded2c86cae5d238511a1e2d8bf7a80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a709e32f5905536216abb03efb4f4db2b"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a709e32f5905536216abb03efb4f4db2b">contains</a> (struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> **states, int len, struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *state)</td></tr>
<tr class="memdesc:a709e32f5905536216abb03efb4f4db2b"><td class="mdescLeft">&#160;</td><td class="mdescRight">helper function to determine an element's presence in an array <br /></td></tr>
<tr class="separator:a709e32f5905536216abb03efb4f4db2b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a34774f1859a742ea1c3eaf3f6726b66c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a34774f1859a742ea1c3eaf3f6726b66c">findEmpty</a> (struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *target, struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> **states, int *sc)</td></tr>
<tr class="memdesc:a34774f1859a742ea1c3eaf3f6726b66c"><td class="mdescLeft">&#160;</td><td class="mdescRight">helper function to manage empty character transitions <br /></td></tr>
<tr class="separator:a34774f1859a742ea1c3eaf3f6726b66c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a38faadeab39bb48716f1065bc05abec8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a> (const char *regex, const char *string, const int expected)</td></tr>
<tr class="memdesc:a38faadeab39bb48716f1065bc05abec8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Testing helper function. <br /></td></tr>
<tr class="separator:a38faadeab39bb48716f1065bc05abec8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a13eda00dd5efd9440b0eaf5430b73e84"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a13eda00dd5efd9440b0eaf5430b73e84">test</a> (void)</td></tr>
<tr class="memdesc:a13eda00dd5efd9440b0eaf5430b73e84"><td class="mdescLeft">&#160;</td><td class="mdescRight">Self-test implementations. <br /></td></tr>
<tr class="separator:a13eda00dd5efd9440b0eaf5430b73e84"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <br /></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a href="https://en.wikipedia.org/wiki/Thompson%27s_construction" target="_blank">McNaughtonYamadaThompson algorithm</a> </p>
<p>From Wikipedia: In computer science, Thompson's construction algorithm, also called the McNaughtonYamadaThompson algorithm, is a method of transforming a regular expression into an equivalent nondeterministic finite automaton (<a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a>). This implementation implements the all three operations (implicit concatenation, '|' for union, '*' for Kleene star) required by the formal definition of regular expressions. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/CascadingCascade" target="_blank">Sharon Cassidy</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a4ed0049e15d45e0d75a991fbb6f8963c" name="a4ed0049e15d45e0d75a991fbb6f8963c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4ed0049e15d45e0d75a991fbb6f8963c">&#9670;&#160;</a></span>addRule()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void addRule </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a> *&#160;</td>
<td class="paramname"><em>rule</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>loc</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>adds a transition rule to a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
<tr><td class="paramname">rule</td><td>the rule to be added </td></tr>
<tr><td class="paramname">loc</td><td>which state this rule should be added to </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 380</span> {</div>
<div class="line"><span class="lineno"> 381</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">rulePool</a>[nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a7087a5c8f402de41f50d38f7fdf99f74">ruleCount</a>++] = rule;</div>
<div class="line"><span class="lineno"> 382</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>* state = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[loc];</div>
<div class="line"><span class="lineno"> 383</span> state-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">rules</a>[state-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aab70804a0b5849410e61f51a225d3072">ruleCount</a>++] = rule;</div>
<div class="line"><span class="lineno"> 384</span>}</div>
<div class="ttc" id="astruct_n_f_a_html_a6d263fee53d282bdb1536ad2134bd532"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">NFA::rulePool</a></div><div class="ttdeci">struct transRule ** rulePool</div><div class="ttdoc">the pool of all transition rules</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:74</div></div>
<div class="ttc" id="astruct_n_f_a_html_a7087a5c8f402de41f50d38f7fdf99f74"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a7087a5c8f402de41f50d38f7fdf99f74">NFA::ruleCount</a></div><div class="ttdeci">int ruleCount</div><div class="ttdoc">the total number of transition rules in this NFA</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:73</div></div>
<div class="ttc" id="astruct_n_f_a_html_aaf1fe7a48e3990c7cc9ec5cba8c82d02"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">NFA::statePool</a></div><div class="ttdeci">struct NFAState ** statePool</div><div class="ttdoc">the pool of all available states</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:72</div></div>
<div class="ttc" id="astruct_n_f_a_state_html"><div class="ttname"><a href="../../d4/d97/struct_n_f_a_state.html">NFAState</a></div><div class="ttdoc">Definition for a NFA state.</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:54</div></div>
<div class="ttc" id="astruct_n_f_a_state_html_aab70804a0b5849410e61f51a225d3072"><div class="ttname"><a href="../../d4/d97/struct_n_f_a_state.html#aab70804a0b5849410e61f51a225d3072">NFAState::ruleCount</a></div><div class="ttdeci">int ruleCount</div><div class="ttdoc">number of transition rules this state have</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:55</div></div>
<div class="ttc" id="astruct_n_f_a_state_html_aca9718d26eff08bb41418c5ec3442381"><div class="ttname"><a href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">NFAState::rules</a></div><div class="ttdeci">struct transRule ** rules</div><div class="ttdoc">the transition rules</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:56</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a799974b5bc43a844a200715db21b1124" name="a799974b5bc43a844a200715db21b1124"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a799974b5bc43a844a200715db21b1124">&#9670;&#160;</a></span>addState()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void addState </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>state</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>adds a state to a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
<tr><td class="paramname">state</td><td>the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state to be added </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 369</span> {</div>
<div class="line"><span class="lineno"> 370</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a1f68cf1d2a14e9e3035baba764dd3df7">stateCount</a>++] = state;</div>
<div class="line"><span class="lineno"> 371</span>}</div>
<div class="ttc" id="astruct_n_f_a_html_a1f68cf1d2a14e9e3035baba764dd3df7"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a1f68cf1d2a14e9e3035baba764dd3df7">NFA::stateCount</a></div><div class="ttdeci">int stateCount</div><div class="ttdoc">the total number of states this NFA have</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:71</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a496e9b4e45417ac56dac40bbbb769d7a" name="a496e9b4e45417ac56dac40bbbb769d7a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a496e9b4e45417ac56dac40bbbb769d7a">&#9670;&#160;</a></span>buildAST()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> * buildAST </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>input</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>recursively constructs a AST from a preprocessed regex string </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">input</td><td>regex </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the resulting tree </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 189</span> {</div>
<div class="line"><span class="lineno"> 190</span> </div>
<div class="line"><span class="lineno"> 191</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a>* <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a12df013d848665fdcdcb01870c322af6">createNode</a>(<span class="charliteral">&#39;\0&#39;</span>);</div>
<div class="line"><span class="lineno"> 192</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a> = NULL;</div>
<div class="line"><span class="lineno"> 193</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a> = NULL;</div>
<div class="line"><span class="lineno"> 194</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> len = strlen(input);</div>
<div class="line"><span class="lineno"> 195</span> <span class="keywordtype">size_t</span> index;</div>
<div class="line"><span class="lineno"> 196</span> </div>
<div class="line"><span class="lineno"> 197</span> <span class="comment">// Empty input</span></div>
<div class="line"><span class="lineno"> 198</span> <span class="keywordflow">if</span>(len == 0) <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 199</span> </div>
<div class="line"><span class="lineno"> 200</span> <span class="comment">// Character literals</span></div>
<div class="line"><span class="lineno"> 201</span> <span class="keywordflow">if</span>(len == 1) {</div>
<div class="line"><span class="lineno"> 202</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;content = input[0];</div>
<div class="line"><span class="lineno"> 203</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 204</span> }</div>
<div class="line"><span class="lineno"> 205</span> </div>
<div class="line"><span class="lineno"> 206</span> <span class="comment">// Discard parentheses</span></div>
<div class="line"><span class="lineno"> 207</span> <span class="keywordflow">if</span>(input[0] == <span class="charliteral">&#39;(&#39;</span> &amp;&amp; input[len - 1] == <span class="charliteral">&#39;)&#39;</span>) {</div>
<div class="line"><span class="lineno"> 208</span> <span class="keywordtype">char</span>* temp = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a>(input, 1, len - 2);</div>
<div class="line"><span class="lineno"> 209</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6a97ab2db6392f262b03370689872348">destroyNode</a>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>);</div>
<div class="line"><span class="lineno"> 210</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp);</div>
<div class="line"><span class="lineno"> 211</span> </div>
<div class="line"><span class="lineno"> 212</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp);</div>
<div class="line"><span class="lineno"> 213</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 214</span> }</div>
<div class="line"><span class="lineno"> 215</span> </div>
<div class="line"><span class="lineno"> 216</span> <span class="comment">// Union</span></div>
<div class="line"><span class="lineno"> 217</span> index = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aab463320a19667bd604db2405abefd55">indexOf</a>(input, <span class="charliteral">&#39;|&#39;</span>);</div>
<div class="line"><span class="lineno"> 218</span> <span class="keywordflow">if</span>(index) {</div>
<div class="line"><span class="lineno"> 219</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;content = <span class="charliteral">&#39;|&#39;</span>;</div>
<div class="line"><span class="lineno"> 220</span> </div>
<div class="line"><span class="lineno"> 221</span> <span class="keywordtype">char</span>* temp1 = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a>(input, 0, index - 1);</div>
<div class="line"><span class="lineno"> 222</span> <span class="keywordtype">char</span>* temp2 = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a>(input, index + 1, len - 1);</div>
<div class="line"><span class="lineno"> 223</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp1);</div>
<div class="line"><span class="lineno"> 224</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp2);</div>
<div class="line"><span class="lineno"> 225</span> </div>
<div class="line"><span class="lineno"> 226</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp2);</div>
<div class="line"><span class="lineno"> 227</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp1);</div>
<div class="line"><span class="lineno"> 228</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 229</span> }</div>
<div class="line"><span class="lineno"> 230</span> </div>
<div class="line"><span class="lineno"> 231</span> <span class="comment">// Concatenation</span></div>
<div class="line"><span class="lineno"> 232</span> index = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aab463320a19667bd604db2405abefd55">indexOf</a>(input, <span class="charliteral">&#39;\n&#39;</span>);</div>
<div class="line"><span class="lineno"> 233</span> <span class="keywordflow">if</span>(index) {</div>
<div class="line"><span class="lineno"> 234</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;content = <span class="charliteral">&#39;\n&#39;</span>;</div>
<div class="line"><span class="lineno"> 235</span> </div>
<div class="line"><span class="lineno"> 236</span> <span class="keywordtype">char</span>* temp1 = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a>(input, 0, index - 1);</div>
<div class="line"><span class="lineno"> 237</span> <span class="keywordtype">char</span>* temp2 = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a>(input, index + 1, len - 1);</div>
<div class="line"><span class="lineno"> 238</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp1);</div>
<div class="line"><span class="lineno"> 239</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp2);</div>
<div class="line"><span class="lineno"> 240</span> </div>
<div class="line"><span class="lineno"> 241</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp2);</div>
<div class="line"><span class="lineno"> 242</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp1);</div>
<div class="line"><span class="lineno"> 243</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 244</span> }</div>
<div class="line"><span class="lineno"> 245</span> </div>
<div class="line"><span class="lineno"> 246</span> <span class="comment">// Kleene star</span></div>
<div class="line"><span class="lineno"> 247</span> <span class="comment">// Testing with indexOf() is unnecessary here,</span></div>
<div class="line"><span class="lineno"> 248</span> <span class="comment">// Since all other possibilities have been exhausted</span></div>
<div class="line"><span class="lineno"> 249</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;content = <span class="charliteral">&#39;*&#39;</span>;</div>
<div class="line"><span class="lineno"> 250</span> <span class="keywordtype">char</span>* temp = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a>(input, 0, len - 2);</div>
<div class="line"><span class="lineno"> 251</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp);</div>
<div class="line"><span class="lineno"> 252</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a> = NULL;</div>
<div class="line"><span class="lineno"> 253</span> </div>
<div class="line"><span class="lineno"> 254</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp);</div>
<div class="line"><span class="lineno"> 255</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 256</span>}</div>
<div class="ttc" id="amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768"><div class="ttname"><a href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a></div><div class="ttdeci">#define free(ptr)</div><div class="ttdoc">This macro replace the standard free function with free_dbg.</div><div class="ttdef"><b>Definition:</b> malloc_dbg.h:26</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a072d13f905ab9438d38d7415df222817"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a072d13f905ab9438d38d7415df222817">subString</a></div><div class="ttdeci">char * subString(const char *str, size_t begin, size_t end)</div><div class="ttdoc">utility function to create a subString</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:177</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a12df013d848665fdcdcb01870c322af6"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a12df013d848665fdcdcb01870c322af6">createNode</a></div><div class="ttdeci">struct ASTNode * createNode(char content)</div><div class="ttdoc">creates and initializes a AST node</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:606</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a496e9b4e45417ac56dac40bbbb769d7a"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a></div><div class="ttdeci">struct ASTNode * buildAST(const char *input)</div><div class="ttdoc">recursively constructs a AST from a preprocessed regex string</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:189</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a6a97ab2db6392f262b03370689872348"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6a97ab2db6392f262b03370689872348">destroyNode</a></div><div class="ttdeci">void destroyNode(struct ASTNode *node)</div><div class="ttdoc">recursively destroys a AST</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:619</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_aab463320a19667bd604db2405abefd55"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aab463320a19667bd604db2405abefd55">indexOf</a></div><div class="ttdeci">size_t indexOf(const char *str, char key)</div><div class="ttdoc">utility function to locate the first occurrence of a character in a string while respecting parenthes...</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:151</div></div>
<div class="ttc" id="astruct_a_s_t_node_html"><div class="ttname"><a href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a></div><div class="ttdoc">for assert()</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:27</div></div>
<div class="ttc" id="astructnode_html"><div class="ttname"><a href="../../d5/da1/structnode.html">node</a></div><div class="ttdoc">Node, the basic data structure in the tree.</div><div class="ttdef"><b>Definition:</b> binary_search_tree.c:15</div></div>
<div class="ttc" id="astructnode_html_a51e160f22dc6064bac4a4f9f1d931c2c"><div class="ttname"><a href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">node::right</a></div><div class="ttdeci">struct node * right</div><div class="ttdoc">right child</div><div class="ttdef"><b>Definition:</b> binary_search_tree.c:17</div></div>
<div class="ttc" id="astructnode_html_af7109e6ffd82cbbb705e486fd0ce92f0"><div class="ttname"><a href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">node::left</a></div><div class="ttdeci">struct node * left</div><div class="ttdoc">left child</div><div class="ttdef"><b>Definition:</b> binary_search_tree.c:16</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a496e9b4e45417ac56dac40bbbb769d7a_cgraph.svg" width="330" height="208"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ac3ded2c86cae5d238511a1e2d8bf7a80" name="ac3ded2c86cae5d238511a1e2d8bf7a80"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac3ded2c86cae5d238511a1e2d8bf7a80">&#9670;&#160;</a></span>compileFromAST()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> * compileFromAST </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> *&#160;</td>
<td class="paramname"><em>root</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<div class="fragment"><div class="line"><span class="lineno"> 279</span> {</div>
<div class="line"><span class="lineno"> 280</span> </div>
<div class="line"><span class="lineno"> 281</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* nfa = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a2491d4e9e630ebb9880260379779cf63">createNFA</a>();</div>
<div class="line"><span class="lineno"> 282</span> </div>
<div class="line"><span class="lineno"> 283</span> <span class="comment">// Empty input</span></div>
<div class="line"><span class="lineno"> 284</span> <span class="keywordflow">if</span> (root-&gt;content == <span class="charliteral">&#39;\0&#39;</span>) {</div>
<div class="line"><span class="lineno"> 285</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], <span class="charliteral">&#39;\0&#39;</span>), 0);</div>
<div class="line"><span class="lineno"> 286</span> <span class="keywordflow">return</span> nfa;</div>
<div class="line"><span class="lineno"> 287</span> }</div>
<div class="line"><span class="lineno"> 288</span> </div>
<div class="line"><span class="lineno"> 289</span> <span class="comment">// Character literals</span></div>
<div class="line"><span class="lineno"> 290</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a>(root-&gt;content)) {</div>
<div class="line"><span class="lineno"> 291</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], root-&gt;content), 0);</div>
<div class="line"><span class="lineno"> 292</span> <span class="keywordflow">return</span> nfa;</div>
<div class="line"><span class="lineno"> 293</span> }</div>
<div class="line"><span class="lineno"> 294</span> </div>
<div class="line"><span class="lineno"> 295</span> <span class="keywordflow">switch</span> (root-&gt;content) {</div>
<div class="line"><span class="lineno"> 296</span> </div>
<div class="line"><span class="lineno"> 297</span> <span class="keywordflow">case</span> <span class="charliteral">&#39;\n&#39;</span>: {</div>
<div class="line"><span class="lineno"> 298</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* ln = compileFromAST(root-&gt;left);</div>
<div class="line"><span class="lineno"> 299</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* rn = compileFromAST(root-&gt;right);</div>
<div class="line"><span class="lineno"> 300</span> </div>
<div class="line"><span class="lineno"> 301</span> <span class="comment">// Redirects all rules targeting ln&#39;s accepting state to</span></div>
<div class="line"><span class="lineno"> 302</span> <span class="comment">// target rn&#39;s starting state</span></div>
<div class="line"><span class="lineno"> 303</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#af1fbbb13a173dbacb0d4195923ab6cb3">redirect</a>(ln, ln-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], rn-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0]);</div>
<div class="line"><span class="lineno"> 304</span> </div>
<div class="line"><span class="lineno"> 305</span> <span class="comment">// Manually creates and initializes a special</span></div>
<div class="line"><span class="lineno"> 306</span> <span class="comment">// &quot;wrapper&quot; NFA</span></div>
<div class="line"><span class="lineno"> 307</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a684ed3494e22ee17d7b3e19a4d1fe977">destroyNFA</a>(nfa);</div>
<div class="line"><span class="lineno"> 308</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* wrapper = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>));</div>
<div class="line"><span class="lineno"> 309</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a1f68cf1d2a14e9e3035baba764dd3df7">stateCount</a> = 2;</div>
<div class="line"><span class="lineno"> 310</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 2);</div>
<div class="line"><span class="lineno"> 311</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a> = 0;</div>
<div class="line"><span class="lineno"> 312</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>*) * 2);</div>
<div class="line"><span class="lineno"> 313</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a7087a5c8f402de41f50d38f7fdf99f74">ruleCount</a> = 0;</div>
<div class="line"><span class="lineno"> 314</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">rulePool</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a>*) * 3);</div>
<div class="line"><span class="lineno"> 315</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a> = 0;</div>
<div class="line"><span class="lineno"> 316</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 2);</div>
<div class="line"><span class="lineno"> 317</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a46968ad64f39e9c62b8fb7970d494422">wrapperFlag</a> = 1;</div>
<div class="line"><span class="lineno"> 318</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>++] = ln;</div>
<div class="line"><span class="lineno"> 319</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>++] = rn;</div>
<div class="line"><span class="lineno"> 320</span> </div>
<div class="line"><span class="lineno"> 321</span> <span class="comment">// Maps the wrapper NFA&#39;s starting and ending states</span></div>
<div class="line"><span class="lineno"> 322</span> <span class="comment">// to its sub NFAs</span></div>
<div class="line"><span class="lineno"> 323</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0] = ln-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0];</div>
<div class="line"><span class="lineno"> 324</span> wrapper-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1] = rn-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1];</div>
<div class="line"><span class="lineno"> 325</span> </div>
<div class="line"><span class="lineno"> 326</span> <span class="keywordflow">return</span> wrapper;</div>
<div class="line"><span class="lineno"> 327</span> }</div>
<div class="line"><span class="lineno"> 328</span> <span class="keywordflow">case</span> <span class="charliteral">&#39;|&#39;</span>: {</div>
<div class="line"><span class="lineno"> 329</span> </div>
<div class="line"><span class="lineno"> 330</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* ln = compileFromAST(root-&gt;left);</div>
<div class="line"><span class="lineno"> 331</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* rn = compileFromAST(root-&gt;right);</div>
<div class="line"><span class="lineno"> 332</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>++] = ln;</div>
<div class="line"><span class="lineno"> 333</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>++] = rn;</div>
<div class="line"><span class="lineno"> 334</span> </div>
<div class="line"><span class="lineno"> 335</span> <span class="comment">// Adds empty character transition rules</span></div>
<div class="line"><span class="lineno"> 336</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(ln-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0], <span class="charliteral">&#39;\0&#39;</span>), 0);</div>
<div class="line"><span class="lineno"> 337</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(ln, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], <span class="charliteral">&#39;\0&#39;</span>), 1);</div>
<div class="line"><span class="lineno"> 338</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(rn-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0], <span class="charliteral">&#39;\0&#39;</span>), 0);</div>
<div class="line"><span class="lineno"> 339</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(rn, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], <span class="charliteral">&#39;\0&#39;</span>), 1);</div>
<div class="line"><span class="lineno"> 340</span> </div>
<div class="line"><span class="lineno"> 341</span> <span class="keywordflow">return</span> nfa;</div>
<div class="line"><span class="lineno"> 342</span> }</div>
<div class="line"><span class="lineno"> 343</span> <span class="keywordflow">case</span> <span class="charliteral">&#39;*&#39;</span>: {</div>
<div class="line"><span class="lineno"> 344</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* ln = compileFromAST(root-&gt;left);</div>
<div class="line"><span class="lineno"> 345</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>++] = ln;</div>
<div class="line"><span class="lineno"> 346</span> </div>
<div class="line"><span class="lineno"> 347</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(ln, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(ln-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0], <span class="charliteral">&#39;\0&#39;</span>), 1);</div>
<div class="line"><span class="lineno"> 348</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(ln-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0], <span class="charliteral">&#39;\0&#39;</span>), 0);</div>
<div class="line"><span class="lineno"> 349</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(ln, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], <span class="charliteral">&#39;\0&#39;</span>), 1);</div>
<div class="line"><span class="lineno"> 350</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1], <span class="charliteral">&#39;\0&#39;</span>), 0);</div>
<div class="line"><span class="lineno"> 351</span> </div>
<div class="line"><span class="lineno"> 352</span> <span class="keywordflow">return</span> nfa;</div>
<div class="line"><span class="lineno"> 353</span> }</div>
<div class="line"><span class="lineno"> 354</span> }</div>
<div class="line"><span class="lineno"> 355</span> </div>
<div class="line"><span class="lineno"> 356</span> <span class="comment">// Fallback, shouldn&#39;t happen in normal operation</span></div>
<div class="line"><span class="lineno"> 357</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a684ed3494e22ee17d7b3e19a4d1fe977">destroyNFA</a>(nfa);</div>
<div class="line"><span class="lineno"> 358</span> <span class="keywordflow">return</span> NULL;</div>
<div class="line"><span class="lineno"> 359</span>}</div>
<div class="ttc" id="amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee"><div class="ttname"><a href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a></div><div class="ttdeci">#define malloc(bytes)</div><div class="ttdoc">This macro replace the standard malloc function with malloc_dbg.</div><div class="ttdef"><b>Definition:</b> malloc_dbg.h:18</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a0b8d037bf2841dede90be41f5fe1ccdc"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a></div><div class="ttdeci">struct transRule * createRule(struct NFAState *state, char c)</div><div class="ttdoc">creates and initializes a transition rule</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:637</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a2491d4e9e630ebb9880260379779cf63"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a2491d4e9e630ebb9880260379779cf63">createNFA</a></div><div class="ttdeci">struct NFA * createNFA(void)</div><div class="ttdoc">creates and initializes a NFA</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:678</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a4ed0049e15d45e0d75a991fbb6f8963c"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a></div><div class="ttdeci">void addRule(struct NFA *nfa, struct transRule *rule, int loc)</div><div class="ttdoc">adds a transition rule to a NFA</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:380</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a684ed3494e22ee17d7b3e19a4d1fe977"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a684ed3494e22ee17d7b3e19a4d1fe977">destroyNFA</a></div><div class="ttdeci">void destroyNFA(struct NFA *nfa)</div><div class="ttdoc">recursively destroys a NFA</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:701</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a6eaf52853f2b39a1299cc16972a3298e"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a></div><div class="ttdeci">int isLiteral(const char ch)</div><div class="ttdoc">helper function to determine whether a character should be considered a character literal</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:99</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_af1fbbb13a173dbacb0d4195923ab6cb3"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#af1fbbb13a173dbacb0d4195923ab6cb3">redirect</a></div><div class="ttdeci">void redirect(struct NFA *nfa, struct NFAState *src, struct NFAState *dest)</div><div class="ttdoc">helper function to recursively redirect transition rule targets</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:267</div></div>
<div class="ttc" id="astruct_n_f_a_html"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html">NFA</a></div><div class="ttdoc">Definition for the NFA itself.</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:70</div></div>
<div class="ttc" id="astruct_n_f_a_html_a38e4fdb290def5942dc14eff7c6211ba"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">NFA::CSCount</a></div><div class="ttdeci">int CSCount</div><div class="ttdoc">the number of currently active states</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:75</div></div>
<div class="ttc" id="astruct_n_f_a_html_a46968ad64f39e9c62b8fb7970d494422"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a46968ad64f39e9c62b8fb7970d494422">NFA::wrapperFlag</a></div><div class="ttdeci">int wrapperFlag</div><div class="ttdoc">whether this NFA is a concatenation wrapper</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:79</div></div>
<div class="ttc" id="astruct_n_f_a_html_a5e64682c0c21d3f931096b2ef38b5072"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">NFA::subCount</a></div><div class="ttdeci">int subCount</div><div class="ttdoc">the number of sub NFAs</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:77</div></div>
<div class="ttc" id="astruct_n_f_a_html_a9b3eef40ce5b331a6508648b2c32ea00"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">NFA::subs</a></div><div class="ttdeci">struct NFA ** subs</div><div class="ttdoc">the pool of all sub NFAs</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:78</div></div>
<div class="ttc" id="astruct_n_f_a_html_ad400f1830095be00a7fdff804d6405c0"><div class="ttname"><a href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">NFA::currentStates</a></div><div class="ttdeci">struct NFAState ** currentStates</div><div class="ttdoc">the pool of all active states</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:76</div></div>
<div class="ttc" id="astructtrans_rule_html"><div class="ttname"><a href="../../d9/dd9/structtrans_rule.html">transRule</a></div><div class="ttdoc">Definition for a NFA state transition rule.</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:41</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a709e32f5905536216abb03efb4f4db2b" name="a709e32f5905536216abb03efb4f4db2b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a709e32f5905536216abb03efb4f4db2b">&#9670;&#160;</a></span>contains()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int contains </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> **&#160;</td>
<td class="paramname"><em>states</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>state</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>helper function to determine an element's presence in an array </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">states</td><td>target array </td></tr>
<tr><td class="paramname">len</td><td>length of the target array </td></tr>
<tr><td class="paramname">state</td><td>the element to search for </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>1</code> if the element is present, <code>0</code> otherwise </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 428</span> {</div>
<div class="line"><span class="lineno"> 429</span> <span class="keywordtype">int</span> f = 0;</div>
<div class="line"><span class="lineno"> 430</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; len; ++i) {</div>
<div class="line"><span class="lineno"> 431</span> <span class="keywordflow">if</span>(states[i] == state) {</div>
<div class="line"><span class="lineno"> 432</span> f = 1;</div>
<div class="line"><span class="lineno"> 433</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 434</span> }</div>
<div class="line"><span class="lineno"> 435</span> }</div>
<div class="line"><span class="lineno"> 436</span> <span class="keywordflow">return</span> f;</div>
<div class="line"><span class="lineno"> 437</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a2491d4e9e630ebb9880260379779cf63" name="a2491d4e9e630ebb9880260379779cf63"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2491d4e9e630ebb9880260379779cf63">&#9670;&#160;</a></span>createNFA()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> * createNFA </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>creates and initializes a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </p>
<dl class="section return"><dt>Returns</dt><dd>pointer to the newly created <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 678</span> {</div>
<div class="line"><span class="lineno"> 679</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* nfa = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>));</div>
<div class="line"><span class="lineno"> 680</span> </div>
<div class="line"><span class="lineno"> 681</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a1f68cf1d2a14e9e3035baba764dd3df7">stateCount</a> = 0;</div>
<div class="line"><span class="lineno"> 682</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 5);</div>
<div class="line"><span class="lineno"> 683</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a7087a5c8f402de41f50d38f7fdf99f74">ruleCount</a> = 0;</div>
<div class="line"><span class="lineno"> 684</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">rulePool</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a>*) * 10);</div>
<div class="line"><span class="lineno"> 685</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a> = 0;</div>
<div class="line"><span class="lineno"> 686</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 5);</div>
<div class="line"><span class="lineno"> 687</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a> = 0;</div>
<div class="line"><span class="lineno"> 688</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>*) * 5);</div>
<div class="line"><span class="lineno"> 689</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a46968ad64f39e9c62b8fb7970d494422">wrapperFlag</a> = 0;</div>
<div class="line"><span class="lineno"> 690</span> </div>
<div class="line"><span class="lineno"> 691</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a799974b5bc43a844a200715db21b1124">addState</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aa87c20bf2b324829943accce4bbff84a">createState</a>());</div>
<div class="line"><span class="lineno"> 692</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a799974b5bc43a844a200715db21b1124">addState</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aa87c20bf2b324829943accce4bbff84a">createState</a>());</div>
<div class="line"><span class="lineno"> 693</span> <span class="keywordflow">return</span> nfa;</div>
<div class="line"><span class="lineno"> 694</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a799974b5bc43a844a200715db21b1124"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a799974b5bc43a844a200715db21b1124">addState</a></div><div class="ttdeci">void addState(struct NFA *nfa, struct NFAState *state)</div><div class="ttdoc">adds a state to a NFA</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:369</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_aa87c20bf2b324829943accce4bbff84a"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aa87c20bf2b324829943accce4bbff84a">createState</a></div><div class="ttdeci">struct NFAState * createState(void)</div><div class="ttdoc">creates and initializes a NFA state</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:657</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a2491d4e9e630ebb9880260379779cf63_cgraph.svg" width="232" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a12df013d848665fdcdcb01870c322af6" name="a12df013d848665fdcdcb01870c322af6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a12df013d848665fdcdcb01870c322af6">&#9670;&#160;</a></span>createNode()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> * createNode </td>
<td>(</td>
<td class="paramtype">const char&#160;</td>
<td class="paramname"><em>content</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>creates and initializes a AST node </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">content</td><td>data to initializes the node with </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the newly created node </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 606</span> {</div>
<div class="line"><span class="lineno"> 607</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a>* <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a>));</div>
<div class="line"><span class="lineno"> 608</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;content = <a class="code hl_variable" href="../../d8/d66/struct_a_s_t_node.html#af6ca532deb4e4ae30127449bfe5a1970">content</a>;</div>
<div class="line"><span class="lineno"> 609</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a> = NULL;</div>
<div class="line"><span class="lineno"> 610</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a> = NULL;</div>
<div class="line"><span class="lineno"> 611</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>;</div>
<div class="line"><span class="lineno"> 612</span>}</div>
<div class="ttc" id="astruct_a_s_t_node_html_af6ca532deb4e4ae30127449bfe5a1970"><div class="ttname"><a href="../../d8/d66/struct_a_s_t_node.html#af6ca532deb4e4ae30127449bfe5a1970">ASTNode::content</a></div><div class="ttdeci">char content</div><div class="ttdoc">the content of this node</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:28</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a0b8d037bf2841dede90be41f5fe1ccdc" name="a0b8d037bf2841dede90be41f5fe1ccdc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0b8d037bf2841dede90be41f5fe1ccdc">&#9670;&#160;</a></span>createRule()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a> * createRule </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>state</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>c</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>creates and initializes a transition rule </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">state</td><td>transition target </td></tr>
<tr><td class="paramname">c</td><td>transition condition </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the newly created rule </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 637</span> {</div>
<div class="line"><span class="lineno"> 638</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a>* rule = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a>));</div>
<div class="line"><span class="lineno"> 639</span> rule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a> = state;</div>
<div class="line"><span class="lineno"> 640</span> rule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#abd89c7bca6969150c7bbf7d888e4aa6b">cond</a> = c;</div>
<div class="line"><span class="lineno"> 641</span> <span class="keywordflow">return</span> rule;</div>
<div class="line"><span class="lineno"> 642</span>}</div>
<div class="ttc" id="astructtrans_rule_html_a3459db0aa62824b51da3297e431900bd"><div class="ttname"><a href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">transRule::target</a></div><div class="ttdeci">struct NFAState * target</div><div class="ttdoc">pointer to the state to transit to</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:42</div></div>
<div class="ttc" id="astructtrans_rule_html_abd89c7bca6969150c7bbf7d888e4aa6b"><div class="ttname"><a href="../../d9/dd9/structtrans_rule.html#abd89c7bca6969150c7bbf7d888e4aa6b">transRule::cond</a></div><div class="ttdeci">char cond</div><div class="ttdoc">the input required to activate this transition</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:43</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="aa87c20bf2b324829943accce4bbff84a" name="aa87c20bf2b324829943accce4bbff84a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa87c20bf2b324829943accce4bbff84a">&#9670;&#160;</a></span>createState()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> * createState </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>creates and initializes a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state </p>
<dl class="section return"><dt>Returns</dt><dd>pointer to the newly created <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 657</span> {</div>
<div class="line"><span class="lineno"> 658</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>* state = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>));</div>
<div class="line"><span class="lineno"> 659</span> state-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aab70804a0b5849410e61f51a225d3072">ruleCount</a> = 0;</div>
<div class="line"><span class="lineno"> 660</span> state-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">rules</a> = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a>*) * 3);</div>
<div class="line"><span class="lineno"> 661</span> <span class="keywordflow">return</span> state;</div>
<div class="line"><span class="lineno"> 662</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a684ed3494e22ee17d7b3e19a4d1fe977" name="a684ed3494e22ee17d7b3e19a4d1fe977"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a684ed3494e22ee17d7b3e19a4d1fe977">&#9670;&#160;</a></span>destroyNFA()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void destroyNFA </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>recursively destroys a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>pointer to the object to be deleted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 701</span> {</div>
<div class="line"><span class="lineno"> 702</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 703</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a684ed3494e22ee17d7b3e19a4d1fe977">destroyNFA</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[i]);</div>
<div class="line"><span class="lineno"> 704</span> }</div>
<div class="line"><span class="lineno"> 705</span> </div>
<div class="line"><span class="lineno"> 706</span> <span class="comment">// In case of a wrapper NFA, do not free its states</span></div>
<div class="line"><span class="lineno"> 707</span> <span class="comment">// because it doesn&#39;t really have any states of its own</span></div>
<div class="line"><span class="lineno"> 708</span> <span class="keywordflow">if</span> (!nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a46968ad64f39e9c62b8fb7970d494422">wrapperFlag</a>) {</div>
<div class="line"><span class="lineno"> 709</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a1f68cf1d2a14e9e3035baba764dd3df7">stateCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 710</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a9a361f55b51ce6d677e907396fbc1652">destroyState</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[i]);</div>
<div class="line"><span class="lineno"> 711</span> }</div>
<div class="line"><span class="lineno"> 712</span> }</div>
<div class="line"><span class="lineno"> 713</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a7087a5c8f402de41f50d38f7fdf99f74">ruleCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 714</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ade1398311f666988b895f41c3e36d70e">destroyRule</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">rulePool</a>[i]);</div>
<div class="line"><span class="lineno"> 715</span> }</div>
<div class="line"><span class="lineno"> 716</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>);</div>
<div class="line"><span class="lineno"> 717</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>);</div>
<div class="line"><span class="lineno"> 718</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">rulePool</a>);</div>
<div class="line"><span class="lineno"> 719</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>);</div>
<div class="line"><span class="lineno"> 720</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(nfa);</div>
<div class="line"><span class="lineno"> 721</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a9a361f55b51ce6d677e907396fbc1652"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a9a361f55b51ce6d677e907396fbc1652">destroyState</a></div><div class="ttdeci">void destroyState(struct NFAState *state)</div><div class="ttdoc">destroys a NFA state</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:669</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_ade1398311f666988b895f41c3e36d70e"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ade1398311f666988b895f41c3e36d70e">destroyRule</a></div><div class="ttdeci">void destroyRule(struct transRule *rule)</div><div class="ttdoc">destroys a transition rule object</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:649</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a684ed3494e22ee17d7b3e19a4d1fe977_cgraph.svg" width="246" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a6a97ab2db6392f262b03370689872348" name="a6a97ab2db6392f262b03370689872348"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6a97ab2db6392f262b03370689872348">&#9670;&#160;</a></span>destroyNode()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void destroyNode </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a> *&#160;</td>
<td class="paramname"><em>node</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>recursively destroys a AST </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">node</td><td>the root node of the tree to be deleted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 619</span> {</div>
<div class="line"><span class="lineno"> 620</span> <span class="keywordflow">if</span>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a> != NULL) {</div>
<div class="line"><span class="lineno"> 621</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6a97ab2db6392f262b03370689872348">destroyNode</a>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#af7109e6ffd82cbbb705e486fd0ce92f0">left</a>);</div>
<div class="line"><span class="lineno"> 622</span> }</div>
<div class="line"><span class="lineno"> 623</span> </div>
<div class="line"><span class="lineno"> 624</span> <span class="keywordflow">if</span>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a> != NULL) {</div>
<div class="line"><span class="lineno"> 625</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6a97ab2db6392f262b03370689872348">destroyNode</a>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>-&gt;<a class="code hl_variable" href="../../d5/da1/structnode.html#a51e160f22dc6064bac4a4f9f1d931c2c">right</a>);</div>
<div class="line"><span class="lineno"> 626</span> }</div>
<div class="line"><span class="lineno"> 627</span> </div>
<div class="line"><span class="lineno"> 628</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>);</div>
<div class="line"><span class="lineno"> 629</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a6a97ab2db6392f262b03370689872348_cgraph.svg" width="107" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ade1398311f666988b895f41c3e36d70e" name="ade1398311f666988b895f41c3e36d70e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ade1398311f666988b895f41c3e36d70e">&#9670;&#160;</a></span>destroyRule()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void destroyRule </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d9/dd9/structtrans_rule.html">transRule</a> *&#160;</td>
<td class="paramname"><em>rule</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>destroys a transition rule object </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">rule</td><td>pointer to the object to be deleted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 649</span> {</div>
<div class="line"><span class="lineno"> 650</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(rule);</div>
<div class="line"><span class="lineno"> 651</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a9a361f55b51ce6d677e907396fbc1652" name="a9a361f55b51ce6d677e907396fbc1652"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9a361f55b51ce6d677e907396fbc1652">&#9670;&#160;</a></span>destroyState()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void destroyState </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>state</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>destroys a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> state </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">state</td><td>pointer to the object to be deleted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 669</span> {</div>
<div class="line"><span class="lineno"> 670</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(state-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">rules</a>);</div>
<div class="line"><span class="lineno"> 671</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(state);</div>
<div class="line"><span class="lineno"> 672</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a34774f1859a742ea1c3eaf3f6726b66c" name="a34774f1859a742ea1c3eaf3f6726b66c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a34774f1859a742ea1c3eaf3f6726b66c">&#9670;&#160;</a></span>findEmpty()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void findEmpty </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>target</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> **&#160;</td>
<td class="paramname"><em>states</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *&#160;</td>
<td class="paramname"><em>sc</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>helper function to manage empty character transitions </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">target</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
<tr><td class="paramname">states</td><td>pointer to results storage location </td></tr>
<tr><td class="paramname">sc</td><td>pointer to results count storage location </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 446</span> {</div>
<div class="line"><span class="lineno"> 447</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; target-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aab70804a0b5849410e61f51a225d3072">ruleCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 448</span> <span class="keyword">const</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a> *pRule = <a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a>-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">rules</a>[i];</div>
<div class="line"><span class="lineno"> 449</span> </div>
<div class="line"><span class="lineno"> 450</span> <span class="keywordflow">if</span> (pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#abd89c7bca6969150c7bbf7d888e4aa6b">cond</a> == <span class="charliteral">&#39;\0&#39;</span> &amp;&amp; !<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a709e32f5905536216abb03efb4f4db2b">contains</a>(states, *sc, pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a>)) {</div>
<div class="line"><span class="lineno"> 451</span> states[(*sc)++] = pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a>;</div>
<div class="line"><span class="lineno"> 452</span> <span class="comment">// the use of `states` and `sc` is necessary</span></div>
<div class="line"><span class="lineno"> 453</span> <span class="comment">// to sync data across recursion levels</span></div>
<div class="line"><span class="lineno"> 454</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a34774f1859a742ea1c3eaf3f6726b66c">findEmpty</a>(pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a>, states, sc);</div>
<div class="line"><span class="lineno"> 455</span> }</div>
<div class="line"><span class="lineno"> 456</span> }</div>
<div class="line"><span class="lineno"> 457</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a34774f1859a742ea1c3eaf3f6726b66c"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a34774f1859a742ea1c3eaf3f6726b66c">findEmpty</a></div><div class="ttdeci">void findEmpty(struct NFAState *target, struct NFAState **states, int *sc)</div><div class="ttdoc">helper function to manage empty character transitions</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:446</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a709e32f5905536216abb03efb4f4db2b"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a709e32f5905536216abb03efb4f4db2b">contains</a></div><div class="ttdeci">int contains(struct NFAState **states, int len, struct NFAState *state)</div><div class="ttdoc">helper function to determine an element's presence in an array</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:428</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a34774f1859a742ea1c3eaf3f6726b66c_cgraph.svg" width="210" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="aab463320a19667bd604db2405abefd55" name="aab463320a19667bd604db2405abefd55"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aab463320a19667bd604db2405abefd55">&#9670;&#160;</a></span>indexOf()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t indexOf </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>str</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>key</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>utility function to locate the first occurrence of a character in a string while respecting parentheses </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">str</td><td>target string </td></tr>
<tr><td class="paramname">key</td><td>the character to be located </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the index of its first occurrence, <code>0</code> if it could not be found </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 151</span> {</div>
<div class="line"><span class="lineno"> 152</span> <span class="keywordtype">int</span> depth = 0;</div>
<div class="line"><span class="lineno"> 153</span> </div>
<div class="line"><span class="lineno"> 154</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; strlen(str); ++i) {</div>
<div class="line"><span class="lineno"> 155</span> <span class="keyword">const</span> <span class="keywordtype">char</span> c = str[i];</div>
<div class="line"><span class="lineno"> 156</span> </div>
<div class="line"><span class="lineno"> 157</span> <span class="keywordflow">if</span>(depth == 0 &amp;&amp; c == key) {</div>
<div class="line"><span class="lineno"> 158</span> <span class="keywordflow">return</span> i;</div>
<div class="line"><span class="lineno"> 159</span> }</div>
<div class="line"><span class="lineno"> 160</span> <span class="keywordflow">if</span>(c == <span class="charliteral">&#39;(&#39;</span>) depth++;</div>
<div class="line"><span class="lineno"> 161</span> <span class="keywordflow">if</span>(c == <span class="charliteral">&#39;)&#39;</span>) depth--;</div>
<div class="line"><span class="lineno"> 162</span> }</div>
<div class="line"><span class="lineno"> 163</span> <span class="comment">// Due to the way this function is intended to be used,</span></div>
<div class="line"><span class="lineno"> 164</span> <span class="comment">// it&#39;s safe to assume the character will not appear as</span></div>
<div class="line"><span class="lineno"> 165</span> <span class="comment">// the string&#39;s first character</span></div>
<div class="line"><span class="lineno"> 166</span> <span class="comment">// thus `0` is used as the `not found` value</span></div>
<div class="line"><span class="lineno"> 167</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 168</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a2dabcd5c410a4b0cac1b4ab378c9dcdc" name="a2dabcd5c410a4b0cac1b4ab378c9dcdc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2dabcd5c410a4b0cac1b4ab378c9dcdc">&#9670;&#160;</a></span>isAccepting()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int isAccepting </td>
<td>(</td>
<td class="paramtype">const struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>determines whether the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> is currently in its accepting state </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>1</code> if the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> is in its accepting state </dd>
<dd>
<code>0</code> otherwise </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 522</span> {</div>
<div class="line"><span class="lineno"> 523</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 524</span> <span class="keywordflow">if</span>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>[i] == nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[1]) {</div>
<div class="line"><span class="lineno"> 525</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><span class="lineno"> 526</span> }</div>
<div class="line"><span class="lineno"> 527</span> }</div>
<div class="line"><span class="lineno"> 528</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 529</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a6eaf52853f2b39a1299cc16972a3298e" name="a6eaf52853f2b39a1299cc16972a3298e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6eaf52853f2b39a1299cc16972a3298e">&#9670;&#160;</a></span>isLiteral()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int isLiteral </td>
<td>(</td>
<td class="paramtype">const char&#160;</td>
<td class="paramname"><em>ch</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>helper function to determine whether a character should be considered a character literal </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ch</td><td>the character to be tested </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>1</code> if it is a character literal </dd>
<dd>
<code>0</code> otherwise </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 99</span> {</div>
<div class="line"><span class="lineno"> 100</span> <span class="keywordflow">return</span> !(ch == <span class="charliteral">&#39;(&#39;</span> || ch == <span class="charliteral">&#39;)&#39;</span> || ch == <span class="charliteral">&#39;*&#39;</span> || ch == <span class="charliteral">&#39;\n&#39;</span> || ch == <span class="charliteral">&#39;|&#39;</span>);</div>
<div class="line"><span class="lineno"> 101</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a840291bc02cba5474a4cb46a9b9566fe" name="a840291bc02cba5474a4cb46a9b9566fe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a840291bc02cba5474a4cb46a9b9566fe">&#9670;&#160;</a></span>main()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 593</span> {</div>
<div class="line"><span class="lineno"> 594</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a13eda00dd5efd9440b0eaf5430b73e84">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><span class="lineno"> 595</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 596</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a13eda00dd5efd9440b0eaf5430b73e84"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a13eda00dd5efd9440b0eaf5430b73e84">test</a></div><div class="ttdeci">static void test(void)</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:572</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a840291bc02cba5474a4cb46a9b9566fe_cgraph.svg" width="100%" height="600"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
</div>
<a id="a86e0f235783b005e4e6e951c9603bbe1" name="a86e0f235783b005e4e6e951c9603bbe1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a86e0f235783b005e4e6e951c9603bbe1">&#9670;&#160;</a></span>postProcessing()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void postProcessing </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>performs postprocessing on a compiled <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a>, add circular empty character transition rules where it's needed for the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> to function correctly </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 393</span> {</div>
<div class="line"><span class="lineno"> 394</span> <span class="comment">// Since the sub NFA&#39;s states and rules are managed</span></div>
<div class="line"><span class="lineno"> 395</span> <span class="comment">// through their own pools, recursion is necessary</span></div>
<div class="line"><span class="lineno"> 396</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 397</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a86e0f235783b005e4e6e951c9603bbe1">postProcessing</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[i]);</div>
<div class="line"><span class="lineno"> 398</span> }</div>
<div class="line"><span class="lineno"> 399</span> </div>
<div class="line"><span class="lineno"> 400</span> <span class="comment">// If a state does not have any empty character accepting rule,</span></div>
<div class="line"><span class="lineno"> 401</span> <span class="comment">// we add a rule that circles back to itself</span></div>
<div class="line"><span class="lineno"> 402</span> <span class="comment">// So this state will be preserved when</span></div>
<div class="line"><span class="lineno"> 403</span> <span class="comment">// empty characters are inputted</span></div>
<div class="line"><span class="lineno"> 404</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a1f68cf1d2a14e9e3035baba764dd3df7">stateCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 405</span> </div>
<div class="line"><span class="lineno"> 406</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>* pState = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[i];</div>
<div class="line"><span class="lineno"> 407</span> <span class="keywordtype">int</span> f = 0;</div>
<div class="line"><span class="lineno"> 408</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; pState-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aab70804a0b5849410e61f51a225d3072">ruleCount</a>; ++j) {</div>
<div class="line"><span class="lineno"> 409</span> <span class="keywordflow">if</span>(pState-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">rules</a>[j]-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#abd89c7bca6969150c7bbf7d888e4aa6b">cond</a> == <span class="charliteral">&#39;\0&#39;</span>) {</div>
<div class="line"><span class="lineno"> 410</span> f = 1;</div>
<div class="line"><span class="lineno"> 411</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 412</span> }</div>
<div class="line"><span class="lineno"> 413</span> }</div>
<div class="line"><span class="lineno"> 414</span> </div>
<div class="line"><span class="lineno"> 415</span> <span class="keywordflow">if</span> (!f) {</div>
<div class="line"><span class="lineno"> 416</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a4ed0049e15d45e0d75a991fbb6f8963c">addRule</a>(nfa, <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a0b8d037bf2841dede90be41f5fe1ccdc">createRule</a>(pState, <span class="charliteral">&#39;\0&#39;</span>), i);</div>
<div class="line"><span class="lineno"> 417</span> }</div>
<div class="line"><span class="lineno"> 418</span> }</div>
<div class="line"><span class="lineno"> 419</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a86e0f235783b005e4e6e951c9603bbe1"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a86e0f235783b005e4e6e951c9603bbe1">postProcessing</a></div><div class="ttdeci">void postProcessing(struct NFA *nfa)</div><div class="ttdoc">performs postprocessing on a compiled NFA, add circular empty character transition rules where it's n...</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:393</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a86e0f235783b005e4e6e951c9603bbe1_cgraph.svg" width="255" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ae9a5eac7c0d8ac478eb1b97529638fb6" name="ae9a5eac7c0d8ac478eb1b97529638fb6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae9a5eac7c0d8ac478eb1b97529638fb6">&#9670;&#160;</a></span>preProcessing()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char * preProcessing </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>input</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>performs preprocessing on a regex string, making all implicit concatenations explicit </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">input</td><td>target regex string </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the processing result </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 109</span> {</div>
<div class="line"><span class="lineno"> 110</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> len = strlen(input);</div>
<div class="line"><span class="lineno"> 111</span> <span class="keywordflow">if</span>(len == 0) {</div>
<div class="line"><span class="lineno"> 112</span> <span class="keywordtype">char</span>* str = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(1);</div>
<div class="line"><span class="lineno"> 113</span> str[0] = <span class="charliteral">&#39;\0&#39;</span>;</div>
<div class="line"><span class="lineno"> 114</span> <span class="keywordflow">return</span> str;</div>
<div class="line"><span class="lineno"> 115</span> }</div>
<div class="line"><span class="lineno"> 116</span> </div>
<div class="line"><span class="lineno"> 117</span> <span class="keywordtype">char</span>* str = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(len * 2);</div>
<div class="line"><span class="lineno"> 118</span> <span class="keywordtype">size_t</span> op = 0;</div>
<div class="line"><span class="lineno"> 119</span> </div>
<div class="line"><span class="lineno"> 120</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; len - 1; ++i) {</div>
<div class="line"><span class="lineno"> 121</span> <span class="keywordtype">char</span> c = input[i];</div>
<div class="line"><span class="lineno"> 122</span> str[op++] = c;</div>
<div class="line"><span class="lineno"> 123</span> <span class="comment">// one character lookahead</span></div>
<div class="line"><span class="lineno"> 124</span> <span class="keywordtype">char</span> c1 = input[i + 1];</div>
<div class="line"><span class="lineno"> 125</span> </div>
<div class="line"><span class="lineno"> 126</span> <span class="keywordflow">if</span>( (<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a>(c) &amp;&amp; <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a>(c1)) ||</div>
<div class="line"><span class="lineno"> 127</span> (<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a>(c) &amp;&amp; c1 == <span class="charliteral">&#39;(&#39;</span>) ||</div>
<div class="line"><span class="lineno"> 128</span> (c == <span class="charliteral">&#39;)&#39;</span> &amp;&amp; c1 == <span class="charliteral">&#39;(&#39;</span>) ||</div>
<div class="line"><span class="lineno"> 129</span> (c == <span class="charliteral">&#39;)&#39;</span> &amp;&amp; <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a>(c1)) ||</div>
<div class="line"><span class="lineno"> 130</span> (c == <span class="charliteral">&#39;*&#39;</span> &amp;&amp; <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6eaf52853f2b39a1299cc16972a3298e">isLiteral</a>(c1)) ||</div>
<div class="line"><span class="lineno"> 131</span> (c == <span class="charliteral">&#39;*&#39;</span> &amp;&amp; c1 == <span class="charliteral">&#39;(&#39;</span>)</div>
<div class="line"><span class="lineno"> 132</span> ) {</div>
<div class="line"><span class="lineno"> 133</span> <span class="comment">// &#39;\n&#39; is used to represent concatenation</span></div>
<div class="line"><span class="lineno"> 134</span> <span class="comment">// in this implementation</span></div>
<div class="line"><span class="lineno"> 135</span> str[op++] = <span class="charliteral">&#39;\n&#39;</span>;</div>
<div class="line"><span class="lineno"> 136</span> }</div>
<div class="line"><span class="lineno"> 137</span> }</div>
<div class="line"><span class="lineno"> 138</span> </div>
<div class="line"><span class="lineno"> 139</span> str[op++] = input[len - 1];</div>
<div class="line"><span class="lineno"> 140</span> str[op] = <span class="charliteral">&#39;\0&#39;</span>;</div>
<div class="line"><span class="lineno"> 141</span> <span class="keywordflow">return</span> str;</div>
<div class="line"><span class="lineno"> 142</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_ae9a5eac7c0d8ac478eb1b97529638fb6_cgraph.svg" width="230" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="af1fbbb13a173dbacb0d4195923ab6cb3" name="af1fbbb13a173dbacb0d4195923ab6cb3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af1fbbb13a173dbacb0d4195923ab6cb3">&#9670;&#160;</a></span>redirect()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void redirect </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>src</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct <a class="el" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *&#160;</td>
<td class="paramname"><em>dest</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>helper function to recursively redirect transition rule targets </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
<tr><td class="paramname">src</td><td>the state to redirect away from </td></tr>
<tr><td class="paramname">dest</td><td>the state to redirect to </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 267</span> {</div>
<div class="line"><span class="lineno"> 268</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a5e64682c0c21d3f931096b2ef38b5072">subCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 269</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#af1fbbb13a173dbacb0d4195923ab6cb3">redirect</a>(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a9b3eef40ce5b331a6508648b2c32ea00">subs</a>[i], src, dest);</div>
<div class="line"><span class="lineno"> 270</span> }</div>
<div class="line"><span class="lineno"> 271</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a7087a5c8f402de41f50d38f7fdf99f74">ruleCount</a>; ++i) {</div>
<div class="line"><span class="lineno"> 272</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a>* rule = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a6d263fee53d282bdb1536ad2134bd532">rulePool</a>[i];</div>
<div class="line"><span class="lineno"> 273</span> <span class="keywordflow">if</span> (rule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a> == src) {</div>
<div class="line"><span class="lineno"> 274</span> rule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a> = dest;</div>
<div class="line"><span class="lineno"> 275</span> }</div>
<div class="line"><span class="lineno"> 276</span> }</div>
<div class="line"><span class="lineno"> 277</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_af1fbbb13a173dbacb0d4195923ab6cb3_cgraph.svg" width="75" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a072d13f905ab9438d38d7415df222817" name="a072d13f905ab9438d38d7415df222817"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a072d13f905ab9438d38d7415df222817">&#9670;&#160;</a></span>subString()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char * subString </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>str</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>begin</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>end</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>utility function to create a subString </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">str</td><td>target string </td></tr>
<tr><td class="paramname">begin</td><td>starting index, inclusive </td></tr>
<tr><td class="paramname">end</td><td>ending index, inclusive </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the newly created subString </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 177</span> {</div>
<div class="line"><span class="lineno"> 178</span> <span class="keywordtype">char</span>* res = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(end - <a class="code hl_function" href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a> + 2);</div>
<div class="line"><span class="lineno"> 179</span> strncpy(res, str + <a class="code hl_function" href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a>, end - <a class="code hl_function" href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a> + 1);</div>
<div class="line"><span class="lineno"> 180</span> res[end - <a class="code hl_function" href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a> + 1] = <span class="charliteral">&#39;\0&#39;</span>;</div>
<div class="line"><span class="lineno"> 181</span> <span class="keywordflow">return</span> res;</div>
<div class="line"><span class="lineno"> 182</span>}</div>
<div class="ttc" id="avector_8c_html_a1afee8aaf33d741df31a73048cff4473"><div class="ttname"><a href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a></div><div class="ttdeci">void * begin(Vector *vec)</div><div class="ttdoc">This function returns the pointer to the begining of the Vector.</div><div class="ttdef"><b>Definition:</b> vector.c:116</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a072d13f905ab9438d38d7415df222817_cgraph.svg" width="188" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a13eda00dd5efd9440b0eaf5430b73e84" name="a13eda00dd5efd9440b0eaf5430b73e84"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a13eda00dd5efd9440b0eaf5430b73e84">&#9670;&#160;</a></span>test()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static void test </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Self-test implementations. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 572</span> {</div>
<div class="line"><span class="lineno"> 573</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(c|a*b)&quot;</span>, <span class="stringliteral">&quot;c&quot;</span>, 1);</div>
<div class="line"><span class="lineno"> 574</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(c|a*b)&quot;</span>, <span class="stringliteral">&quot;aab&quot;</span>, 1);</div>
<div class="line"><span class="lineno"> 575</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(c|a*b)&quot;</span>, <span class="stringliteral">&quot;ca&quot;</span>, 0);</div>
<div class="line"><span class="lineno"> 576</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(c|a*b)*&quot;</span>, <span class="stringliteral">&quot;caaab&quot;</span>, 1);</div>
<div class="line"><span class="lineno"> 577</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(c|a*b)*&quot;</span>, <span class="stringliteral">&quot;caba&quot;</span>, 0);</div>
<div class="line"><span class="lineno"> 578</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;&quot;</span>, <span class="stringliteral">&quot;&quot;</span>, 1);</div>
<div class="line"><span class="lineno"> 579</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;&quot;</span>, <span class="stringliteral">&quot;1&quot;</span>, 0);</div>
<div class="line"><span class="lineno"> 580</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(0|(1(01*(00)*0)*1)*)*&quot;</span>,<span class="stringliteral">&quot;11&quot;</span>,1);</div>
<div class="line"><span class="lineno"> 581</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(0|(1(01*(00)*0)*1)*)*&quot;</span>,<span class="stringliteral">&quot;110&quot;</span>,1);</div>
<div class="line"><span class="lineno"> 582</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(0|(1(01*(00)*0)*1)*)*&quot;</span>,<span class="stringliteral">&quot;1100&quot;</span>,1);</div>
<div class="line"><span class="lineno"> 583</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(0|(1(01*(00)*0)*1)*)*&quot;</span>,<span class="stringliteral">&quot;10000&quot;</span>,0);</div>
<div class="line"><span class="lineno"> 584</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a>(<span class="stringliteral">&quot;(0|(1(01*(00)*0)*1)*)*&quot;</span>,<span class="stringliteral">&quot;00000&quot;</span>,1);</div>
<div class="line"><span class="lineno"> 585</span> </div>
<div class="line"><span class="lineno"> 586</span> printf(<span class="stringliteral">&quot;All tests have successfully passed!\n&quot;</span>);</div>
<div class="line"><span class="lineno"> 587</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a38faadeab39bb48716f1065bc05abec8"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a38faadeab39bb48716f1065bc05abec8">testHelper</a></div><div class="ttdeci">void testHelper(const char *regex, const char *string, const int expected)</div><div class="ttdoc">Testing helper function.</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:540</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a13eda00dd5efd9440b0eaf5430b73e84_cgraph.svg" width="604" height="580"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a38faadeab39bb48716f1065bc05abec8" name="a38faadeab39bb48716f1065bc05abec8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a38faadeab39bb48716f1065bc05abec8">&#9670;&#160;</a></span>testHelper()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void testHelper </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>regex</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>string</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const int&#160;</td>
<td class="paramname"><em>expected</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Testing helper function. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">regex</td><td>the regular expression to be used </td></tr>
<tr><td class="paramname">string</td><td>the string to match against </td></tr>
<tr><td class="paramname">expected</td><td>expected results </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 540</span> {</div>
<div class="line"><span class="lineno"> 541</span> <span class="keywordtype">char</span>* temp = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ae9a5eac7c0d8ac478eb1b97529638fb6">preProcessing</a>(regex);</div>
<div class="line"><span class="lineno"> 542</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d8/d66/struct_a_s_t_node.html">ASTNode</a>* <a class="code hl_struct" href="../../d5/da1/structnode.html">node</a> = <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a496e9b4e45417ac56dac40bbbb769d7a">buildAST</a>(temp);</div>
<div class="line"><span class="lineno"> 543</span> </div>
<div class="line"><span class="lineno"> 544</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d3/dd7/struct_n_f_a.html">NFA</a>* nfa = compileFromAST(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>);</div>
<div class="line"><span class="lineno"> 545</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a86e0f235783b005e4e6e951c9603bbe1">postProcessing</a>(nfa);</div>
<div class="line"><span class="lineno"> 546</span> </div>
<div class="line"><span class="lineno"> 547</span> <span class="comment">// reallocates the outermost NFA&#39;s current states pool</span></div>
<div class="line"><span class="lineno"> 548</span> <span class="comment">// because it will actually be used to store all the states</span></div>
<div class="line"><span class="lineno"> 549</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a> = realloc(nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 100);</div>
<div class="line"><span class="lineno"> 550</span> <span class="comment">// Starts the NFA by adding its starting state to the pool</span></div>
<div class="line"><span class="lineno"> 551</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>[nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a>++] = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#aaf1fe7a48e3990c7cc9ec5cba8c82d02">statePool</a>[0];</div>
<div class="line"><span class="lineno"> 552</span> </div>
<div class="line"><span class="lineno"> 553</span> <span class="comment">// feeds empty characters into the NFA before and after</span></div>
<div class="line"><span class="lineno"> 554</span> <span class="comment">// every normal character</span></div>
<div class="line"><span class="lineno"> 555</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; strlen(<span class="keywordtype">string</span>); ++i) {</div>
<div class="line"><span class="lineno"> 556</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aebe16fbf12c8ac089501ebcae6f0c050">transit</a>(nfa, <span class="charliteral">&#39;\0&#39;</span>);</div>
<div class="line"><span class="lineno"> 557</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aebe16fbf12c8ac089501ebcae6f0c050">transit</a>(nfa, <span class="keywordtype">string</span>[i]);</div>
<div class="line"><span class="lineno"> 558</span> }</div>
<div class="line"><span class="lineno"> 559</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aebe16fbf12c8ac089501ebcae6f0c050">transit</a>(nfa, <span class="charliteral">&#39;\0&#39;</span>);</div>
<div class="line"><span class="lineno"> 560</span> </div>
<div class="line"><span class="lineno"> 561</span> assert(<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a2dabcd5c410a4b0cac1b4ab378c9dcdc">isAccepting</a>(nfa) == expected);</div>
<div class="line"><span class="lineno"> 562</span> </div>
<div class="line"><span class="lineno"> 563</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a684ed3494e22ee17d7b3e19a4d1fe977">destroyNFA</a>(nfa);</div>
<div class="line"><span class="lineno"> 564</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a6a97ab2db6392f262b03370689872348">destroyNode</a>(<a class="code hl_struct" href="../../d5/da1/structnode.html">node</a>);</div>
<div class="line"><span class="lineno"> 565</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(temp);</div>
<div class="line"><span class="lineno"> 566</span>}</div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_a2dabcd5c410a4b0cac1b4ab378c9dcdc"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a2dabcd5c410a4b0cac1b4ab378c9dcdc">isAccepting</a></div><div class="ttdeci">int isAccepting(const struct NFA *nfa)</div><div class="ttdoc">determines whether the NFA is currently in its accepting state</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:522</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_ae9a5eac7c0d8ac478eb1b97529638fb6"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#ae9a5eac7c0d8ac478eb1b97529638fb6">preProcessing</a></div><div class="ttdeci">char * preProcessing(const char *input)</div><div class="ttdoc">performs preprocessing on a regex string, making all implicit concatenations explicit</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:109</div></div>
<div class="ttc" id="amcnaughton__yamada__thompson_8c_html_aebe16fbf12c8ac089501ebcae6f0c050"><div class="ttname"><a href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#aebe16fbf12c8ac089501ebcae6f0c050">transit</a></div><div class="ttdeci">void transit(struct NFA *nfa, char input)</div><div class="ttdoc">moves a NFA forward</div><div class="ttdef"><b>Definition:</b> mcnaughton_yamada_thompson.c:465</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_a38faadeab39bb48716f1065bc05abec8_cgraph.svg" width="514" height="580"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="aebe16fbf12c8ac089501ebcae6f0c050" name="aebe16fbf12c8ac089501ebcae6f0c050"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aebe16fbf12c8ac089501ebcae6f0c050">&#9670;&#160;</a></span>transit()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void transit </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../d3/dd7/struct_n_f_a.html">NFA</a> *&#160;</td>
<td class="paramname"><em>nfa</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>input</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>moves a <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> forward </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">nfa</td><td>target <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
<tr><td class="paramname">input</td><td>the character to be fed into the <a class="el" href="../../d3/dd7/struct_n_f_a.html" title="Definition for the NFA itself.">NFA</a> </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 465</span> {</div>
<div class="line"><span class="lineno"> 466</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>** newStates = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 10);</div>
<div class="line"><span class="lineno"> 467</span> <span class="keywordtype">int</span> NSCount = 0;</div>
<div class="line"><span class="lineno"> 468</span> </div>
<div class="line"><span class="lineno"> 469</span> <span class="keywordflow">if</span> (input == <span class="charliteral">&#39;\0&#39;</span>) {</div>
<div class="line"><span class="lineno"> 470</span> <span class="comment">// In case of empty character input, it&#39;s possible for</span></div>
<div class="line"><span class="lineno"> 471</span> <span class="comment">// a state to transit to another state that&#39;s more than</span></div>
<div class="line"><span class="lineno"> 472</span> <span class="comment">// one rule away, we need to take that into account</span></div>
<div class="line"><span class="lineno"> 473</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a> - 1; i &gt; -1; --i) {</div>
<div class="line"><span class="lineno"> 474</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *pState = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>[i];</div>
<div class="line"><span class="lineno"> 475</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a>--;</div>
<div class="line"><span class="lineno"> 476</span> </div>
<div class="line"><span class="lineno"> 477</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>** states = <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a>*) * 10);</div>
<div class="line"><span class="lineno"> 478</span> <span class="keywordtype">int</span> sc = 0;</div>
<div class="line"><span class="lineno"> 479</span> <a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a34774f1859a742ea1c3eaf3f6726b66c">findEmpty</a>(pState, states, &amp;sc);</div>
<div class="line"><span class="lineno"> 480</span> </div>
<div class="line"><span class="lineno"> 481</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; sc; ++j) {</div>
<div class="line"><span class="lineno"> 482</span> <span class="keywordflow">if</span>(!<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a709e32f5905536216abb03efb4f4db2b">contains</a>(newStates,NSCount, states[j])) {</div>
<div class="line"><span class="lineno"> 483</span> newStates[NSCount++] = states[j];</div>
<div class="line"><span class="lineno"> 484</span> }</div>
<div class="line"><span class="lineno"> 485</span> }</div>
<div class="line"><span class="lineno"> 486</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(states);</div>
<div class="line"><span class="lineno"> 487</span> }</div>
<div class="line"><span class="lineno"> 488</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 489</span> <span class="comment">// Iterates through all current states</span></div>
<div class="line"><span class="lineno"> 490</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a> - 1; i &gt; -1; --i) {</div>
<div class="line"><span class="lineno"> 491</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d4/d97/struct_n_f_a_state.html">NFAState</a> *pState = nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>[i];</div>
<div class="line"><span class="lineno"> 492</span> <span class="comment">// Gradually empties the current states pool, so</span></div>
<div class="line"><span class="lineno"> 493</span> <span class="comment">// it can be refilled</span></div>
<div class="line"><span class="lineno"> 494</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a>--;</div>
<div class="line"><span class="lineno"> 495</span> </div>
<div class="line"><span class="lineno"> 496</span> <span class="comment">// Iterates through rules of this state</span></div>
<div class="line"><span class="lineno"> 497</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; pState-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aab70804a0b5849410e61f51a225d3072">ruleCount</a>; ++j) {</div>
<div class="line"><span class="lineno"> 498</span> <span class="keyword">const</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d9/dd9/structtrans_rule.html">transRule</a> *pRule = pState-&gt;<a class="code hl_variable" href="../../d4/d97/struct_n_f_a_state.html#aca9718d26eff08bb41418c5ec3442381">rules</a>[j];</div>
<div class="line"><span class="lineno"> 499</span> </div>
<div class="line"><span class="lineno"> 500</span> <span class="keywordflow">if</span>(pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#abd89c7bca6969150c7bbf7d888e4aa6b">cond</a> == input) {</div>
<div class="line"><span class="lineno"> 501</span> <span class="keywordflow">if</span>(!<a class="code hl_function" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html#a709e32f5905536216abb03efb4f4db2b">contains</a>(newStates, NSCount, pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a>)) {</div>
<div class="line"><span class="lineno"> 502</span> newStates[NSCount++] = pRule-&gt;<a class="code hl_variable" href="../../d9/dd9/structtrans_rule.html#a3459db0aa62824b51da3297e431900bd">target</a>;</div>
<div class="line"><span class="lineno"> 503</span> }</div>
<div class="line"><span class="lineno"> 504</span> }</div>
<div class="line"><span class="lineno"> 505</span> }</div>
<div class="line"><span class="lineno"> 506</span> }</div>
<div class="line"><span class="lineno"> 507</span> }</div>
<div class="line"><span class="lineno"> 508</span> </div>
<div class="line"><span class="lineno"> 509</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#a38e4fdb290def5942dc14eff7c6211ba">CSCount</a> = NSCount;</div>
<div class="line"><span class="lineno"> 510</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; NSCount; ++i) {</div>
<div class="line"><span class="lineno"> 511</span> nfa-&gt;<a class="code hl_variable" href="../../d3/dd7/struct_n_f_a.html#ad400f1830095be00a7fdff804d6405c0">currentStates</a>[i] = newStates[i];</div>
<div class="line"><span class="lineno"> 512</span> }</div>
<div class="line"><span class="lineno"> 513</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(newStates);</div>
<div class="line"><span class="lineno"> 514</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d2e/mcnaughton__yamada__thompson_8c_aebe16fbf12c8ac089501ebcae6f0c050_cgraph.svg" width="315" height="75"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_a52f4d3d586a58b02f3a4ddf0a992157.html">misc</a></li><li class="navelem"><a class="el" href="../../dd/d2e/mcnaughton__yamada__thompson_8c.html">mcnaughton_yamada_thompson.c</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
</ul>
</div>
</body>
</html>