instaparse

If you're not trampolining your parser, why bother getting up in the morning?
mbjarland 2017-12-20T09:52:01.000293Z

say I have the following grammar:

(defn make-layout-parser-internal []
  (insta/parser
    "layout-string = col-delim (col-align col-delim)+
     col-delim    = (col-fill | col-padding)*
     col-fill     = ('F' | 'f')
     col-padding  = #'[^\\[\\]fF]*'
     col-align    = <'['> ('L' | 'l' | 'C' | 'c' | 'R' | 'r') <']'>"))
but I want to make a slight modification to it in a certain context. In essence I have two grammars with just a slight differentce between them and depending on the surrounding (non instaparse related) programming context I would like to parse using either grammar a or grammar b. Would I need to define two distinct grammars as per the above or is there some good way to share most of the grammar and have just a slight modification? In my specific case I would have a difference in the col-align value only