In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you that the Python run is a sample analysis defined by Graminit.c, which is concise and easy to understand, and can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Graminit.c defines the static data needed for parsing at Python runtime (some of the data, mainly Accelerator, will be calculated at run time), in the following order:
Static arc arcs_0_0 [3] = {{2,1}, {3,1}, {4,2},}; static arc arcs_0_1 [1] = {{0,1},}; static arc arcs_0_2 [1] = {{2,1},}; static state states_0 [3] = {{3, arcs_0_0}, {1, arcs_0_1}, {1, arcs_0_2},}
Arc_0_0 represents all arc,arcs_0_1 starting from state 0 in DFA0 represents all arc starting from state 1 in DFA0, and so on. In Arcs_0_0, Arc {2,1} represents an edge from state 0 to state 1. Label2 label is 2 (it can be found later that label2 stands for NEWLINE, that is, a newline character). States_0 records all edges above all status nodes in DFA0.
After defining the state and edge information of all the DFA, we then define an array of all the DFA:
Static dfa dfas [84] = {
{256, "single_input", 0,3, states_0
"\ 004\ 050\ 014\ 000\ 000\ 000\ 025\ 074\ 005\ 023\
310\ 011\ 020\ 004\ 000\ 300\ 020\ 222\ 006\ 201 "}
{257, "file_input", 0,2, states_1
"\ 204\ 050\ 014\ 000\ 000\ 000\ 025\ 074\ 005\ 023
\ 310\ 011\ 020\ 004\ 000\ 300\ 020\ 222\ 006\ 201 "}
...
Graminit.c defines the order of static data needed for parsing at Python runtime. For example, 256elements can be found in graminit.h to represent single_input, that is, interactive mode to issue order statements. The initial state is 0 and there are three states. The corresponding state and edge information are stored in states_0. A very long string of * * represents the firstset of the non-terminal, and each byte corresponds to the ID of label.
Next, graminit.c defines all the Labels:
Static label labels = {{0, "EMPTY"}, {256,0}, {4,0}, {267,0},...
{0, "EMPTY"} is a special edge indicating that the state is the accept state and represents the end of the DFA. {256,0} means that the label corresponds to the symbol 256, that is, single_input, and there is no corresponding string description. Because each keyword appears directly in the syntax, each keyword is defined in Label.
*, which defines grammar:
Grammar _ PyParser_Grammar = {84, dfas, {168,256} labels}
As you can see, the syntax of the entire Python2.5 has 84 rules / DFA,168 Label, with a starting Label of 256and single_input. (some of the data is mainly Accelerator and will be calculated at run time.)
The above is that Python runs a sample analysis that is defined by Graminit.c. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.