Recent Changes

Wednesday, June 14

  1. 5:14 am

Monday, June 5

  1. page WhosUsingPyparsing edited ... Coconut is a functional programming language that compiles to Python. Coconut enhances the rep…
    ...
    Coconut is a functional programming language that compiles to Python. Coconut enhances the repertoire of Python programmers to include the tools of modern functional programming, in such a way that those tools are easy to use and immensely powerful; that is, Coconut does to functional programming what Python did to imperative programming.
    Coconut uses pyparsing as the heart of its compiler, parsing and transforming Coconut source code into compiled version-independent Python entirely through the power of pyparsing.
    Coconut with Evan Hubinger (podcastinit.com)
    Undebt - Massive, automated code refactoring
    Undebt is a tool built by Yelp.com for fast, straightforward, reliable code refactoring. Yelp successfully used Undebt to refactor their 3 million line code base.
    Undebt patterns, which define what to replace when refactoring code, are powered by pure pyparsing; Undebt's entire library of patterns are all pyparsing objects.
    Tech Debt and Refactoring at Yelp! with Andrew Mason (podcastinit.com)
    Docket Alarm - Legal Research "Connector" Language
    Docket Alarm uses pyparsing to support complex legal queries. While searching the law, lawyers regularly use a relatively advanced and unique search syntax, which is similar to Boolean searching, but includes a few additions such as stemming (using the ! mark) and proximity searching (using w/N operator). For example, the following query will find all documents that have the words "employment" or "employee", within ten words of the any word that starts with "discrim".
    (view changes)
    2:58 am

Sunday, June 4

  1. page WhosUsingPyparsing edited Contents: Coconut - Simple, elegant, Pythonic functional programming Booleano - Boolean Con…

    Contents:
    Coconut - Simple, elegant, Pythonic functional programming
    Booleano - Boolean Condition Interpreter {new.gif}
    Undebt - Massive, automated code refactoring
    Reverse Snowflake Joins
    Graphite Real-time Graphing CLI
    (view changes)
    10:06 pm
  2. page WhosUsingPyparsing edited ... FileSystemStorage SQL parser Verilog parser Coconut - Simple, elegant, Pythonic functional …
    ...
    FileSystemStorage SQL parser
    Verilog parser
    Coconut - Simple, elegant, Pythonic functional programming
    Coconut is a functional programming language that compiles to Python. Coconut enhances the repertoire of Python programmers to include the tools of modern functional programming, in such a way that those tools are easy to use and immensely powerful; that is, Coconut does to functional programming what Python did to imperative programming.
    Coconut uses pyparsing as the heart of its compiler, parsing and transforming Coconut source code into compiled version-independent Python entirely through the power of pyparsing.
    Undebt - Massive, automated code refactoring
    Undebt is a tool built by Yelp.com for fast, straightforward, reliable code refactoring. Yelp successfully used Undebt to refactor their 3 million line code base.
    Undebt patterns, which define what to replace when refactoring code, are powered by pure pyparsing; Undebt's entire library of patterns are all pyparsing objects.

    Docket Alarm - Legal Research "Connector" Language
    Docket Alarm uses pyparsing to support complex legal queries. While searching the law, lawyers regularly use a relatively advanced and unique search syntax, which is similar to Boolean searching, but includes a few additions such as stemming (using the ! mark) and proximity searching (using w/N operator). For example, the following query will find all documents that have the words "employment" or "employee", within ten words of the any word that starts with "discrim".
    (view changes)
    10:04 pm
  3. msg Formal-Tranlastion message posted Formal-Tranlastion Pyparsing is not super-great at parsing whitespace-significant text, but there is a method called &…
    Formal-Tranlastion
    Pyparsing is not super-great at parsing whitespace-significant text, but there is a method called "indentedBlock" to help you define this. "IndentedBlock" parses text like Python source that uses leading whitespace for grouping. Here is your parser converted to using indentedBlock:
        indent_stack = [1]
        line_expr = pp.Group(pp.Word(pp.alphas) + "level" + pp.empty + pp.restOfLine)
        line_expr.setName('line')
        section = pp.Forward().setName('section')
        block = pp.indentedBlock(section, indent_stack)
        section <<= line_expr + pp.Optional(block)
        parser = pp.OneOrMore(section)
     
        test="""\
        first level config parameter 1-n
         section level config parameter 1-n
          thirt level config parameter 1-n
         level level config parameter 1-n
          thirt level  config parameter 1-n
        first level config parameter 1-n
        first level config parameter 1-n
        """
     
        print("## Test String level based ##")
        print("#############################")
        print(test)
        print("## Test String formal translated ##")
        print("###################################")
        #~ a = "\n".join(map("|".join, parser.parse(test)))
        #~ print(a)
        res = parser.parseString(test)
        res.pprint()
    Prints:
    [['first', 'level', 'config parameter 1-n'],
     [[['section', 'level', 'config parameter 1-n'],
       [[['thirt', 'level', 'config parameter 1-n']]]],
      [['level', 'level', 'config parameter 1-n'],
       [[['thirt', 'level', 'config parameter 1-n']]]]],
     ['first', 'level', 'config parameter 1-n'],
     ['first', 'level', 'config parameter 1-n']]
    You have to provide an external list that indentedBlock will use to track the stack of previous indents, so that unindents get closed properly.

    HTH,
    -- Paul
    2:44 pm

Tuesday, May 30

  1. msg Formal-Tranlastion message posted Formal-Tranlastion Hi I have some text-configuration which has a level-relation-ship with space. Now I have trans…
    Formal-Tranlastion
    Hi

    I have some text-configuration which has a level-relation-ship with space.
    Now I have translatet the configuration in a formal-format so i can parse the output better.

    Can you tell me maybe, how can I achieve the same result with a cleaner pyparsing implementation?

    import sys, traceback
    import pyparsing as pp
     
    class Parser(object):
        def __init__(self):
            self.__config_line = []
            self.__config_all = []
            self.__loc_last = 0
            self.__position_last = 0
            self.__dimension = 5
     
            start = pp.OneOrMore(pp.Word(pp.alphanums + "/" + "\." + "-" + ":"+"!"+"*"))
            a = start+pp.restOfLine
            self.__pattern = pp.Combine(a, joinString='').setParseAction(self.test)
     
        def test(self,s, loc, toks):
     
            position_current = loc - self.__loc_last
            self.__loc_last = loc + 1 + len(toks[0])
            position_delta = position_current - self.__position_last
            self.__position_last = position_current
     
            if position_current == 0:
                self.__config_line = [''] * self.__dimension
                self.__config_line[position_current] = toks[0]
     
            elif position_delta == 0:
                self.__config_line[position_current] = toks[0]
     
            elif position_delta < 0:
                self.__config_line[position_current:self.__dimension] = [''] * (self.__dimension - 1 - position_current)
                self.__config_line[position_current] = toks[0]
     
            elif position_delta > 0:
                self.__config_line[self.__position_last + 1:self.__dimension] = [''] * (self.__dimension - 1 - self.__position_last)
                self.__config_line[position_current] = toks[0]
     
            self.__position_last = position_current
            self.__config_all.append(list(self.__config_line))
     
        def parse(self, line):
            try:
                parsed = self.__pattern.searchString(line)
                return self.__config_all
            except pp.ParseException as x:
                #print x
                #return False
                pass
     
     
    if __name__ == "__main__":
        parser = Parser()
     
        test="""first level config parameter 1-n
     section level config parameter 1-n
      thirt level config parameter 1-n
     level level config parameter 1-n
      thirt level  config parameter 1-n
    first level config parameter 1-n"""
        print "## Test String level based ##"
        print "#############################"
        print test
        a = "\n".join(map("|".join, parser.parse(test)))
        print "## Test String formal translated ##"
        print "###################################"
        print a
    11:39 am

Wednesday, May 10

  1. 5:53 am

Saturday, April 22

  1. msg SkipTo combined with CaselessKeyword gives unexpected results (possible bug) message posted SkipTo combined with CaselessKeyword gives unexpected results (possible bug) Yes, this looks like a bug, I'll get a fix into 2.2.1, but no ETA on that yet. Thanks, -- Paul
    SkipTo combined with CaselessKeyword gives unexpected results (possible bug)
    Yes, this looks like a bug, I'll get a fix into 2.2.1, but no ETA on that yet.

    Thanks,
    -- Paul
    8:26 pm

Friday, April 14

  1. msg SkipTo combined with CaselessKeyword gives unexpected results (possible bug) message posted SkipTo combined with CaselessKeyword gives unexpected results (possible bug) Hi, If I combine CaselessKeyword with SkiptTo, SkipTo stops at non-word boundaries for the keywo…
    SkipTo combined with CaselessKeyword gives unexpected results (possible bug)
    Hi,

    If I combine CaselessKeyword with SkiptTo, SkipTo stops at non-word boundaries for the keyword. The normal Keyword seems not to have this problem.

    Reproducer:
    from pyparsing import *
    kw = CaselessKeyword("KEY")
    st=SkipTo(kw)
    st.parseString("hello KEY")
    st.parseString("helloKEY") # false positive here
    2:06 am

Monday, April 10

  1. msg Parsing mardown-styled text message posted Parsing mardown-styled text In the end, the "StopOnSuffix" class above revealed to be incorrect because we have no wa…
    Parsing mardown-styled text
    In the end, the "StopOnSuffix" class above revealed to be incorrect because we have no way to know how many whitespaces were skipped and hence backtrack properly:
    https://github.com/Lucas-C/linux_configuration/blob/master/languages/python/pyparsing_StopOnSuffix.py#L36

    Hence I made another implementation in the same spirit as CharsNotIn : https://github.com/Lucas-C/linux_configuration/blob/master/languages/python/mindmaps/pseudo_markdown_parser.py#L39
    It is more limited (the forbidden char sequences are stop words) but it works properly.
    4:16 am

More