Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:26:36+00:00 2026-06-11T00:26:36+00:00

I have the sequence of tokens like this: TokenName(alphanum) value(printable) value(printable, optional) value(printable, optional)

  • 0

I have the sequence of tokens like this:

TokenName(alphanum) value(printable) value(printable, optional) value(printable, optional) Literal(';')

by example:

Token1 "stringValue with escaped data eg: \" in it";
Token2 12;
Token3 0xaaaa; // and hex string indicated by 0x
Token4 "value1" 2 0xbbcc;

Result I except is:

[
    ['Token1', 'stringValue with escaped data eg: " in it'],
    ['Token2', 12],
    ['Token3', '0xaaaa'],
    ['Token4', ['value1', 2, '0xbbcc']],
]

Now I have something like this:

import pyparsing as p
non_semi = ''.join(c for c in p.printables if c != ';')
semi = p.Literal(';').suppress()

single_value = p.Word(non_semi) + semi
multi_value = p.Group(
    p.Word(non_semi) +
    p.Word(non_semi) +
    p.Optional(p.Word(non_semi)) +
    semi
)

value = single_value | multi_value
assignment = p.Group(p.Word(p.alphanum) + value)

bnf = p.Group(p.OneOrMore(assignment))
bnf.ignore(p.cStyleComment)

But this code, does not change 12 into int(12) and also gets " chars in strings, can pyparsing handle this value transformations?

EDIT

Ok, I know how to deal with string: QuotedString helps a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:26:38+00:00Added an answer on June 11, 2026 at 12:26 am

    OK, I have found my answers:

    For handling of strings: QuotedString

    For handling of int and other conversions, there is a setParseAction method of a token def, witch can take eg. lambda s, l, t: int(s) param witch will do the trick

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sequence which varies in length e.g. something like: items <- 1:4
I have a sequence like [0, 1, 0, 1, 0, 1, 0] and I
I was wondering if this was possible... I have a sequence of variables that
I have a sequence and I need to find both the minimum value of
I have a function that reads a formatted file. It looks like this: 1;Name_of_the_author;The
i have file like this a,205 b,214 c,223 ,13 and i need to parse
I have a sequence of maps. ;; input [{:country MX, :video 12345, :customer cid1}
I have a sequence of k nodes N1 , N2 , N3 , ...
I have a sequence. a1 = 1 - cos(x); ai = a1 + (-1)^(i-1)
suppose i have a sequence, called TEST_SEQ what would be the correct way of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.