Questions tagged [pyparsing]

The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. The pyparsing module provides a library of classes that client code uses to construct the grammar directly in Python code.

Pyparsing is a Python module for creating and executing simple grammars. This is an alternative approach to the traditional lex/yacc or regular expressions. The pyparsing module provides a library of classes that client code uses to construct the grammar directly in Python code.

981 questions
0
votes
1 answer

Pyparsing pulp error

When I try installing ManPy I got the following error message: error: pyparsing 2.1.4 is installed but pyparsing<=1.9.9 is required by set(['pulp']) I checked the Pyparsing setup, but I didn't find the solution.
0
votes
0 answers

Python: Find #if clauses in Source and replace corresponding blocks

I have source files which contain preprocessor conditional statements. Looking like this: #if A > 0 && (B < 1 || M == 0) #if U == 0 do_something() #endif do_more() #elif A == 0 do_somethingelse() #else print 'asd'; #endif #else…
tim
  • 9,896
  • 20
  • 81
  • 137
0
votes
1 answer

Error in parsing file.log with pyparsing using python

i am wondring if somone could help me please to resolve this error cause I am a beginer in pyparsing and i would like to parse a my log file : Memory: svmem(total=4014465024, available=3451576320, percent=14.0, used=1240055808, free=2774409216,…
yosra
  • 11
  • 4
0
votes
1 answer

Parsing custom structured file with PyParsing

I'm need of help parsing a custom file structured file. As you can see below is the structure. The issue is that I can't seem to parse the structure correctly, namely myOriginalFormula & myBonusType in the same group when I want them seperated for…
user6110843
0
votes
0 answers

In pyparsing, Each doesn't match every element inside it regardless of order

There is certainly the possibility I'm completely misunderstanding what Each does, but from what I understand (from the documentation): Requires all given ParseExpressions to be found, but in any order. Expressions may be separated by whitespace.…
0
votes
1 answer

ParseException from PyParsing via dot2tex

Passing the following dot file as input to dot2tex results in a parse exception. If I remove the ",2", the error disappears. digraph G { node [shape="circle"]; 1,2 [style="filled"]; 1 -> { 2; 3; 4 } 2 -> { 5; 6 } 4 -> { 7; 8 } …
user2023370
  • 10,488
  • 6
  • 50
  • 83
0
votes
1 answer

convert list of tokens into XML output

I have a list of tokens as generated by pyparsing. I need to carry out manipulations on individual tokens in list based on the tokens around them. Currently, I am just using a for loop. Is there any better mechanism for doing this? For instance, a…
Daniel F
  • 340
  • 1
  • 3
  • 16
0
votes
1 answer

python pyparsing "^" vs "|" keywords

I have a small testcase created to illustrate a problem I am seeing with the "^" operator. When I try and use the ^ operator instead of the | operator below, I get an error. Edit: Just to make the question clearer (although it has already been…
Gregory Kuhn
  • 1,627
  • 2
  • 22
  • 34
0
votes
1 answer

Reading multiple lines from QTextedit

I'm trying to write my own code-editor, I figure its a good way to learn pyQt. I am using a qtextedit, in which i can write code(it's not real code, more pseudo code). Each line represents ending in a semi-colon represents some…
user595985
  • 1,543
  • 4
  • 29
  • 55
0
votes
0 answers

Python Pyparsing Optional field

I am currently using pyparsing module to create my own interpreter. My current code is import pyparsing as pp # To parse a packet with srcip,dstip,srcmac,dstmac identifier = pp.Word(pp.alphas,pp.alphanums+'_') ipfield =…
0
votes
0 answers

Replace variable name taking care of shadow variables

I'm parsing a GLSL source code and I need to replace global variable name with a new name. The problem is how to take care of shadow variable? For example, in the following source code, I would like to replace lines a = 1 and a = 3 but not a = 2…
Nicolas Rougier
  • 670
  • 7
  • 15
0
votes
1 answer

parsing unstructured text using pyparsing in Python

I have hundreds of company report .txt files, and I want to extract some information from it. For example, one part of the file looks like this: Mr. Davido will receive a base salary of $700,000 during the initial and any subsequent term. The Chief…
Brad
  • 569
  • 1
  • 4
  • 8
0
votes
3 answers

Parse a sequence of binary digits

How can I parse sequence of binary digits in python. Following is an example for what i am trying to do. I have a sequence of binary digits, for example sequence = '1110110100110111011011110101100101100' and, I need to parse this and extract the…
user2109788
  • 1,266
  • 2
  • 12
  • 29
0
votes
2 answers

How to use pyparsing to parse and hash strings enclosed by special characters?

The majority of pyparsing examples that I have seen have dealt with linear expressions. a = 1 + 2 I'd like to parse mediawiki headlines, and hash them to their sections. e.g. Introduction goes here ==Hello== foo foo ===World=== bar bar Dict would…
torger
  • 2,308
  • 4
  • 28
  • 35
0
votes
1 answer

scanString end location: why it is end_index+1?

python/pyparsing When I use scanString method, it is giving the start and end location of the matched token, in the text. e.g. line = "cat bat" pat = Word(alphas) for i in pat.scanString(line): print i I get the following: ((['cat'], {}), 0,…
M K Saravanan
  • 359
  • 1
  • 4
  • 12