NodeVisitor class for PEG parser in PythonPartial String split in BashCode Coverage for COBOL code in a Jenkins pipelineRepresenting an AST in C with different structs for types of nodesHow is parser rule precedence chosen with left recursion and a greedy '?' operator?Get all parts of a parenthesisfull expressionCalling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?How do I parse a string to a float or int?Does Python have a ternary conditional operator?How to get the current time in PythonWhy can't Python parse this JSON data?Does Python have a string 'contains' substring method?

Is it possible to take a database offline when doing a backup using an SQL job?

French license plates

Would a 737 pilot use flaps in nose dive?

Was the ruling that prorogation was unlawful only possible because of the creation of a separate supreme court?

If someone asks a question using “quién”, how can one shortly respond?

Why has Speaker Pelosi been so hesitant to impeach President Trump?

Should I be on the paper from another PhD student that I constantly went on his meetings?

Creating specific options in `Manipulate[]`

Duck, duck, gone!

Is there any site with telescopes data?

Would a horse be sufficient buffer to prevent injury when falling from a great height?

Convert a string of digits from words to an integer

Is there a faster way or keyboard shortcut to close files without saving in Preview?

IEEE 754 square root with Newton-Raphson

How to add the real hostname in the beginning of Linux cli command

Are devices supposed to automatically be removed from iCloud when all content and settings are erased?

Why would an airline put 15 passengers at once on standby?

How do we know neutrons have no charge?

How to identify whether a publisher is genuine or not?

As a team leader is it appropriate to bring in fundraiser candy?

Earliest time frog can jump to the other side of a river in C#. Codility's task

How to work around players whose backstory goes against the story?

What would happen if I build a half bath without permits?

Avoiding dust scattering when you drill



NodeVisitor class for PEG parser in Python


Partial String split in BashCode Coverage for COBOL code in a Jenkins pipelineRepresenting an AST in C with different structs for types of nodesHow is parser rule precedence chosen with left recursion and a greedy '?' operator?Get all parts of a parenthesisfull expressionCalling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?How do I parse a string to a float or int?Does Python have a ternary conditional operator?How to get the current time in PythonWhy can't Python parse this JSON data?Does Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















Imagine the following types of strings:



if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)


Now, I'd like to get the expressions in parentheses, so I wrote a PEG parser with the following grammar:



from parsimonious.grammar import Grammar

grammar = Grammar(
r"""
program = if expr+
expr = term (operator term)*
term = (factor operator factor) / factor
factor = (lpar word operator word rpar) / (lpar expr rpar)

if = "if" ws
and = "and"
or = "or"
operator = ws? (and / or) ws?

word = ~"w+"
lpar = "("
rpar = ")"

ws = ~"s*"
""")


which parses just fine with



tree = grammar.parse(string)


Now the question arises: how to write a NodeVisitor class for this tree to get only the factors? My problem here is the second branch which can be deeply nested.




I tried with

def walk(node, level = 0):
if node.expr.name == "factor":
print(level * "-", node.text)

for child in node.children:
walk(child, level + 1)

walk(tree)


but to no avail, really (factors bubble up in duplicates).

Note: This question is based on another one on StackOverflow.










share|improve this question
































    3















    Imagine the following types of strings:



    if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)


    Now, I'd like to get the expressions in parentheses, so I wrote a PEG parser with the following grammar:



    from parsimonious.grammar import Grammar

    grammar = Grammar(
    r"""
    program = if expr+
    expr = term (operator term)*
    term = (factor operator factor) / factor
    factor = (lpar word operator word rpar) / (lpar expr rpar)

    if = "if" ws
    and = "and"
    or = "or"
    operator = ws? (and / or) ws?

    word = ~"w+"
    lpar = "("
    rpar = ")"

    ws = ~"s*"
    """)


    which parses just fine with



    tree = grammar.parse(string)


    Now the question arises: how to write a NodeVisitor class for this tree to get only the factors? My problem here is the second branch which can be deeply nested.




    I tried with

    def walk(node, level = 0):
    if node.expr.name == "factor":
    print(level * "-", node.text)

    for child in node.children:
    walk(child, level + 1)

    walk(tree)


    but to no avail, really (factors bubble up in duplicates).

    Note: This question is based on another one on StackOverflow.










    share|improve this question




























      3












      3








      3








      Imagine the following types of strings:



      if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)


      Now, I'd like to get the expressions in parentheses, so I wrote a PEG parser with the following grammar:



      from parsimonious.grammar import Grammar

      grammar = Grammar(
      r"""
      program = if expr+
      expr = term (operator term)*
      term = (factor operator factor) / factor
      factor = (lpar word operator word rpar) / (lpar expr rpar)

      if = "if" ws
      and = "and"
      or = "or"
      operator = ws? (and / or) ws?

      word = ~"w+"
      lpar = "("
      rpar = ")"

      ws = ~"s*"
      """)


      which parses just fine with



      tree = grammar.parse(string)


      Now the question arises: how to write a NodeVisitor class for this tree to get only the factors? My problem here is the second branch which can be deeply nested.




      I tried with

      def walk(node, level = 0):
      if node.expr.name == "factor":
      print(level * "-", node.text)

      for child in node.children:
      walk(child, level + 1)

      walk(tree)


      but to no avail, really (factors bubble up in duplicates).

      Note: This question is based on another one on StackOverflow.










      share|improve this question
















      Imagine the following types of strings:



      if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)


      Now, I'd like to get the expressions in parentheses, so I wrote a PEG parser with the following grammar:



      from parsimonious.grammar import Grammar

      grammar = Grammar(
      r"""
      program = if expr+
      expr = term (operator term)*
      term = (factor operator factor) / factor
      factor = (lpar word operator word rpar) / (lpar expr rpar)

      if = "if" ws
      and = "and"
      or = "or"
      operator = ws? (and / or) ws?

      word = ~"w+"
      lpar = "("
      rpar = ")"

      ws = ~"s*"
      """)


      which parses just fine with



      tree = grammar.parse(string)


      Now the question arises: how to write a NodeVisitor class for this tree to get only the factors? My problem here is the second branch which can be deeply nested.




      I tried with

      def walk(node, level = 0):
      if node.expr.name == "factor":
      print(level * "-", node.text)

      for child in node.children:
      walk(child, level + 1)

      walk(tree)


      but to no avail, really (factors bubble up in duplicates).

      Note: This question is based on another one on StackOverflow.







      python regex parsing parsimonious






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 19:47









      sophros

      3,8343 gold badges14 silver badges39 bronze badges




      3,8343 gold badges14 silver badges39 bronze badges










      asked Mar 28 at 19:00









      JanJan

      27.4k5 gold badges31 silver badges55 bronze badges




      27.4k5 gold badges31 silver badges55 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          2







          +250










          How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts?




          You could create a visitor that "listens" when a node in the parse tree is a (, in which a depth-variable is increased, and when a ) is encountered, the depth-variable is decreased. Then in the method that is called that matches a parenthesised expression, you inspect the depth before adding it to your list of expressions to return from the visitor.



          Here a is a quick example:



          from parsimonious.grammar import Grammar
          from parsimonious.nodes import NodeVisitor

          grammar = Grammar(
          r"""
          program = if expr+
          expr = term (operator term)*
          term = (lpar expr rpar) / word

          if = "if" ws
          and = "and"
          or = "or"
          operator = ws? (and / or) ws?

          word = ~"w+"
          lpar = "("
          rpar = ")"

          ws = ~"s*"
          """)


          class ParExprVisitor(NodeVisitor):

          def __init__(self):
          self.depth = 0
          self.par_expr = []

          def visit_term(self, node, visited_children):
          if self.depth == 0:
          self.par_expr.append(node.text)

          def visit_lpar(self, node, visited_children):
          self.depth += 1

          def visit_rpar(self, node, visited_children):
          self.depth -= 1

          def generic_visit(self, node, visited_children):
          return self.par_expr


          tree = grammar.parse("if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)")
          visitor = ParExprVisitor()

          for expr in visitor.visit(tree):
          print(expr)


          which prints:



          ((a1 and b) or (a2 and c))
          (c and d)
          (e and f)





          share|improve this answer



























          • Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

            – Jan
            Apr 1 at 18:44






          • 1





            Ah, I see. Let me have a quick look.

            – Bart Kiers
            Apr 1 at 18:51











          • That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

            – Jan
            Apr 1 at 19:39






          • 1





            Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

            – Bart Kiers
            Apr 1 at 19:42


















          1
















          If you only want to return each outermost factor, return early and do not descend into its children.



          def walk(node, level = 0):
          if node.expr.name == "factor":
          print(level * "-", node.text)
          return
          for child in node.children:
          walk(child, level + 1)


          Output:



          ----- ((a1 and b) or (a2 and c))
          ----- (c and d)
          ------ (e and f)





          share|improve this answer

























          • Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

            – Jan
            Apr 1 at 18:45













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405055%2fnodevisitor-class-for-peg-parser-in-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2







          +250










          How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts?




          You could create a visitor that "listens" when a node in the parse tree is a (, in which a depth-variable is increased, and when a ) is encountered, the depth-variable is decreased. Then in the method that is called that matches a parenthesised expression, you inspect the depth before adding it to your list of expressions to return from the visitor.



          Here a is a quick example:



          from parsimonious.grammar import Grammar
          from parsimonious.nodes import NodeVisitor

          grammar = Grammar(
          r"""
          program = if expr+
          expr = term (operator term)*
          term = (lpar expr rpar) / word

          if = "if" ws
          and = "and"
          or = "or"
          operator = ws? (and / or) ws?

          word = ~"w+"
          lpar = "("
          rpar = ")"

          ws = ~"s*"
          """)


          class ParExprVisitor(NodeVisitor):

          def __init__(self):
          self.depth = 0
          self.par_expr = []

          def visit_term(self, node, visited_children):
          if self.depth == 0:
          self.par_expr.append(node.text)

          def visit_lpar(self, node, visited_children):
          self.depth += 1

          def visit_rpar(self, node, visited_children):
          self.depth -= 1

          def generic_visit(self, node, visited_children):
          return self.par_expr


          tree = grammar.parse("if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)")
          visitor = ParExprVisitor()

          for expr in visitor.visit(tree):
          print(expr)


          which prints:



          ((a1 and b) or (a2 and c))
          (c and d)
          (e and f)





          share|improve this answer



























          • Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

            – Jan
            Apr 1 at 18:44






          • 1





            Ah, I see. Let me have a quick look.

            – Bart Kiers
            Apr 1 at 18:51











          • That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

            – Jan
            Apr 1 at 19:39






          • 1





            Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

            – Bart Kiers
            Apr 1 at 19:42















          2







          +250










          How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts?




          You could create a visitor that "listens" when a node in the parse tree is a (, in which a depth-variable is increased, and when a ) is encountered, the depth-variable is decreased. Then in the method that is called that matches a parenthesised expression, you inspect the depth before adding it to your list of expressions to return from the visitor.



          Here a is a quick example:



          from parsimonious.grammar import Grammar
          from parsimonious.nodes import NodeVisitor

          grammar = Grammar(
          r"""
          program = if expr+
          expr = term (operator term)*
          term = (lpar expr rpar) / word

          if = "if" ws
          and = "and"
          or = "or"
          operator = ws? (and / or) ws?

          word = ~"w+"
          lpar = "("
          rpar = ")"

          ws = ~"s*"
          """)


          class ParExprVisitor(NodeVisitor):

          def __init__(self):
          self.depth = 0
          self.par_expr = []

          def visit_term(self, node, visited_children):
          if self.depth == 0:
          self.par_expr.append(node.text)

          def visit_lpar(self, node, visited_children):
          self.depth += 1

          def visit_rpar(self, node, visited_children):
          self.depth -= 1

          def generic_visit(self, node, visited_children):
          return self.par_expr


          tree = grammar.parse("if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)")
          visitor = ParExprVisitor()

          for expr in visitor.visit(tree):
          print(expr)


          which prints:



          ((a1 and b) or (a2 and c))
          (c and d)
          (e and f)





          share|improve this answer



























          • Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

            – Jan
            Apr 1 at 18:44






          • 1





            Ah, I see. Let me have a quick look.

            – Bart Kiers
            Apr 1 at 18:51











          • That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

            – Jan
            Apr 1 at 19:39






          • 1





            Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

            – Bart Kiers
            Apr 1 at 19:42













          2







          +250







          2







          +250



          2






          +250






          How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts?




          You could create a visitor that "listens" when a node in the parse tree is a (, in which a depth-variable is increased, and when a ) is encountered, the depth-variable is decreased. Then in the method that is called that matches a parenthesised expression, you inspect the depth before adding it to your list of expressions to return from the visitor.



          Here a is a quick example:



          from parsimonious.grammar import Grammar
          from parsimonious.nodes import NodeVisitor

          grammar = Grammar(
          r"""
          program = if expr+
          expr = term (operator term)*
          term = (lpar expr rpar) / word

          if = "if" ws
          and = "and"
          or = "or"
          operator = ws? (and / or) ws?

          word = ~"w+"
          lpar = "("
          rpar = ")"

          ws = ~"s*"
          """)


          class ParExprVisitor(NodeVisitor):

          def __init__(self):
          self.depth = 0
          self.par_expr = []

          def visit_term(self, node, visited_children):
          if self.depth == 0:
          self.par_expr.append(node.text)

          def visit_lpar(self, node, visited_children):
          self.depth += 1

          def visit_rpar(self, node, visited_children):
          self.depth -= 1

          def generic_visit(self, node, visited_children):
          return self.par_expr


          tree = grammar.parse("if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)")
          visitor = ParExprVisitor()

          for expr in visitor.visit(tree):
          print(expr)


          which prints:



          ((a1 and b) or (a2 and c))
          (c and d)
          (e and f)





          share|improve this answer
















          How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts?




          You could create a visitor that "listens" when a node in the parse tree is a (, in which a depth-variable is increased, and when a ) is encountered, the depth-variable is decreased. Then in the method that is called that matches a parenthesised expression, you inspect the depth before adding it to your list of expressions to return from the visitor.



          Here a is a quick example:



          from parsimonious.grammar import Grammar
          from parsimonious.nodes import NodeVisitor

          grammar = Grammar(
          r"""
          program = if expr+
          expr = term (operator term)*
          term = (lpar expr rpar) / word

          if = "if" ws
          and = "and"
          or = "or"
          operator = ws? (and / or) ws?

          word = ~"w+"
          lpar = "("
          rpar = ")"

          ws = ~"s*"
          """)


          class ParExprVisitor(NodeVisitor):

          def __init__(self):
          self.depth = 0
          self.par_expr = []

          def visit_term(self, node, visited_children):
          if self.depth == 0:
          self.par_expr.append(node.text)

          def visit_lpar(self, node, visited_children):
          self.depth += 1

          def visit_rpar(self, node, visited_children):
          self.depth -= 1

          def generic_visit(self, node, visited_children):
          return self.par_expr


          tree = grammar.parse("if ((a1 and b) or (a2 and c)) or (c and d) or (e and f)")
          visitor = ParExprVisitor()

          for expr in visitor.visit(tree):
          print(expr)


          which prints:



          ((a1 and b) or (a2 and c))
          (c and d)
          (e and f)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 1 at 19:31

























          answered Apr 1 at 18:38









          Bart KiersBart Kiers

          137k30 gold badges256 silver badges255 bronze badges




          137k30 gold badges256 silver badges255 bronze badges















          • Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

            – Jan
            Apr 1 at 18:44






          • 1





            Ah, I see. Let me have a quick look.

            – Bart Kiers
            Apr 1 at 18:51











          • That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

            – Jan
            Apr 1 at 19:39






          • 1





            Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

            – Bart Kiers
            Apr 1 at 19:42

















          • Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

            – Jan
            Apr 1 at 18:44






          • 1





            Ah, I see. Let me have a quick look.

            – Bart Kiers
            Apr 1 at 18:51











          • That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

            – Jan
            Apr 1 at 19:39






          • 1





            Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

            – Bart Kiers
            Apr 1 at 19:42
















          Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

          – Jan
          Apr 1 at 18:44





          Thanks. How would I go about it to get ((a1 and b) or (a2 and c)), (c and d) and (e and f) as three parts? Sorry for not being clear in the original question here. The main question imo is how to write a recursive NodeVisitor class.

          – Jan
          Apr 1 at 18:44




          1




          1





          Ah, I see. Let me have a quick look.

          – Bart Kiers
          Apr 1 at 18:51





          Ah, I see. Let me have a quick look.

          – Bart Kiers
          Apr 1 at 18:51













          That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

          – Jan
          Apr 1 at 19:39





          That's a clever one! I'd wait another couple of days with the bounty but that is definately interesting.

          – Jan
          Apr 1 at 19:39




          1




          1





          Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

          – Bart Kiers
          Apr 1 at 19:42





          Sure, no problem, I answered because I didn't know this parsimonious library, which looked nice. I might have a closer look at it.

          – Bart Kiers
          Apr 1 at 19:42













          1
















          If you only want to return each outermost factor, return early and do not descend into its children.



          def walk(node, level = 0):
          if node.expr.name == "factor":
          print(level * "-", node.text)
          return
          for child in node.children:
          walk(child, level + 1)


          Output:



          ----- ((a1 and b) or (a2 and c))
          ----- (c and d)
          ------ (e and f)





          share|improve this answer

























          • Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

            – Jan
            Apr 1 at 18:45















          1
















          If you only want to return each outermost factor, return early and do not descend into its children.



          def walk(node, level = 0):
          if node.expr.name == "factor":
          print(level * "-", node.text)
          return
          for child in node.children:
          walk(child, level + 1)


          Output:



          ----- ((a1 and b) or (a2 and c))
          ----- (c and d)
          ------ (e and f)





          share|improve this answer

























          • Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

            – Jan
            Apr 1 at 18:45













          1














          1










          1









          If you only want to return each outermost factor, return early and do not descend into its children.



          def walk(node, level = 0):
          if node.expr.name == "factor":
          print(level * "-", node.text)
          return
          for child in node.children:
          walk(child, level + 1)


          Output:



          ----- ((a1 and b) or (a2 and c))
          ----- (c and d)
          ------ (e and f)





          share|improve this answer













          If you only want to return each outermost factor, return early and do not descend into its children.



          def walk(node, level = 0):
          if node.expr.name == "factor":
          print(level * "-", node.text)
          return
          for child in node.children:
          walk(child, level + 1)


          Output:



          ----- ((a1 and b) or (a2 and c))
          ----- (c and d)
          ------ (e and f)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 31 at 20:33









          Jan-GerdJan-Gerd

          7923 silver badges7 bronze badges




          7923 silver badges7 bronze badges















          • Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

            – Jan
            Apr 1 at 18:45

















          • Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

            – Jan
            Apr 1 at 18:45
















          Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

          – Jan
          Apr 1 at 18:45





          Thanks for your response. However I am merely looking for a NodeVisitor solution or a hint to reformulate the grammar. With the early returns one can't do anything with the output.

          – Jan
          Apr 1 at 18:45


















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405055%2fnodevisitor-class-for-peg-parser-in-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript