Install Python parser function declaration

Source: Internet
Author: User

In the standard Python parser, the restrictions on the default variable values are very vague. Based on this, many compilers allow developers to include default variable values in function declaration, pointer and reference to function, member function pointer, and typedef declaration.

First, we will first understand DParser, a simple and powerful parsing tool written by J. Plevyak. Then I learned about the DParser for Python. It provides a seamless interface for Python programmers to access DParser and compares it with the parser introduced in the previous section. Syntax Rules are added to DParser using Python function document strings in a way similar to Spark or PLY. There are many available Python parser libraries.

What is the difference between DParser and all other Resolvers? In this case, similar to PLY and Spark, the DParser for Python uses the function document string to represent the result productions ). This style allows you to insert Action Code directly into a result to process events that will occur when a specific syntax rule is satisfied.

In contrast to PLY or Spark, DParser itself is written in C and may be much faster than a pure Python parser. DParser for Python is a very streamlined wrapper outside the underlying C library)-It takes some extra time for Python callback.

However, the basic Parsing is based on the speed of the C language. However, as far as this article is concerned, I have not tried any specific benchmark tests. Therefore, compared with other parsers, the speed or slowness of DParser is not something I can directly comment on. Many readers recommend that Python DParaser is worth noting. By the way, as you will see in the example, DParser does not use any separate flag for passing.

Instead, it is directly parsed. You can control space identification by defining the reserved d_whitespace () function. This allows you to use tags at will. The results that follow the question mark are speculative attempts; those that follow the question mark do not actually have the final results. Related to this, DParser enables you to take different actions when the results become speculative or ultimately parsed.

By default, the action in the function body only acts on final parsing. However, you can specify one of two additional parameters to the result to handle speculative parsing. There are many option parameters not discussed in this article .) Despite receiving some suggestions from readers, I still do not pay much attention to DParser. It has many powerful switches and options that can act on the results. I have not discussed them yet-for example, specifying associations.

In general, the DParser language is very robust and I doubt whether the DParser for Python runs much faster than the pure Python parser. In any case, I still cannot have too much enthusiasm for the string-style parser in the function documentation. Obviously, many excellent Python programmers will not agree with me on this point.

In addition, I also found that some parsing results are somewhat confusing: why can the debugging mode be successful, but not in standard mode? When exactly did the vague question occur? Using any parsing tool to develop syntaxes can be similar, but I find that DParser is especially unexpected somehow. For example, SimpleParse won't surprise me.

Maybe, if I understand more complex details about the underlying algorithm, it will be more meaningful. However, as far as I am concerned, I may be similar to more than 95% of readers. Some people are more familiar with parsing than I do, but most programmers actually know less.

Python is a powerful high-level scripting language. It is powerful not only in its own functions, but also in its excellent scalability, python has been favored by more and more people and has been successfully applied to the development of various large software systems.

Different from other common scripting languages, Python programmers can use APIs provided by the Python language to use C or C ++ for Functional extension of Python, in this way, you can use Python's convenient and flexible syntax and functions, and obtain almost the same execution performance as C or C ++.

Slow execution speed is a common feature of almost all scripting languages, and it is also an important factor that has been criticized. Python cleverly solves this problem through the organic combination with the C language, therefore, the application scope of the script language is greatly extended.

When developing a real software system using a Python parser, C/C ++ is often used to expand Python. The most common situation is that a library written in C already exists, and some functions of this library need to be used in Python.

In this case, you can use the extension function provided by Python. In addition, because Python is essentially a scripting language, it is difficult for some functions to be implemented using Python to meet the execution efficiency requirements of the actual software system, in this case, you can use the extension function provided by Python to implement these key code segments in C or C ++ to provide program execution performance.

  1. Introduction to Python system files
  2. How to correctly use Python Functions
  3. Detailed introduction and analysis of Python build tools
  4. Advantages of Python in PythonAndroid
  5. How to Use the Python module to parse the configuration file?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.