title: Is adaptive parsing possible in Prolog?
body: <p>I am attempting to write an <a href="https://www.google.com/search?q=%22adaptive+%28grammar%7Cparser%29%22+-site%3Astackoverflow.com" rel="nofollow">adaptive parser</a> in Prolog: in other words, a parser that can modify its own parsing rules at runtime.</p>
  
  <p>In order to do this, I'll need to generate new predicates at runtime, but I'm not sure if this is possible. Would it be possible to write a predicate that takes a list like this one:</p>
  
  <pre><code>generate_dcg_rule([A," is greater than ",B]).
  </code></pre>
  
  <p>...and then generates a new predicate like this one?</p>
  
  <pre><code>expr(A," is greater than ",B) --&gt;
      symbol(A)," is greater than ",symbol(B).
  </code></pre>