I am seeking for a method to parse single lines of Python code (infact
they are only formulas, so I generate a line like RESULT=<formula >). I
do only want to know if the syntax is correct and if there is an error
best would be to know where.
I did find PyParser_Simple ParseString which does return a node
structure. If there is an error it seems to return NULL, while I did
not find this documented.
Th eproblem with this is that first I do not get th elopcation of the
syntax error, and second I don't know what is the proper method to free
the node structure after I got it, since I will not use it. Or is there
any better method doing this anyway.
Environment: Windows / Borland C++ 3 1653 ga************* *@web.de wrote: I am seeking for a method to parse single lines of Python code (infact they are only formulas, so I generate a line like RESULT=<formula >). I do only want to know if the syntax is correct and if there is an error best would be to know where.
I did find PyParser_Simple ParseString which does return a node structure. If there is an error it seems to return NULL, while I did not find this documented.
Th eproblem with this is that first I do not get th elopcation of the syntax error, and second I don't know what is the proper method to free the node structure after I got it, since I will not use it. Or is there any better method doing this anyway.
A better way might be to use the standard library compiler module. A
file called cptools.py (part of the cherrypy project) has a very simple
example called 'unrepr' which shows how to do it.
I only have restricted internet access or I would find the URL for you
(sorry).
Fuzzyman http://www.voidspace.org.uk/python/index.shtml
Environment: Windows / Borland C++ ga************* *@web.de wrote: I am seeking for a method to parse single lines of Python code (infact they are only formulas, so I generate a line like RESULT=<formula >). I do only want to know if the syntax is correct and if there is an error best would be to know where.
I did find PyParser_Simple ParseString which does return a node structure. If there is an error it seems to return NULL, while I did not find this documented.
Th eproblem with this is that first I do not get th elopcation of the syntax error, and second I don't know what is the proper method to free the node structure after I got it, since I will not use it. Or is there any better method doing this anyway.
Environment: Windows / Borland C++
The builtin function compile will throw a SyntaxError if the syntax is
bad. compile("1=a"," ","single")
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
SyntaxError: can't assign to literal
Thanks for th eanswers so far.
But as you can see from the function I use, I do need an interface
function to do th ejob from C++. I canno timagine there is no clean way
to do this. Calling th epython interpreter to execute a compule
function in python and then get the output parsed to get th eerror
message i snot an option. The strange thing however is that I have
tried to use th ecompile interface function first and this one did
return an error. I supposed this was because th ewhole context did not
exist so I went to the "parse only" function.
The main question I have is what to do with the pointer to the node
structure returned by this function, as freeing th epointer with free()
throws an error. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Clifford W. Racz |
last post by:
Does anyone know of a decent tool, preferably free, that will check and validate DTD syntax, to make sure that my DTD is correct?
The only tool that I have found thus far is the IBM visual DTD tool, which I do like, but is limited. Basically, your DTD is "good" when it parses... and I am not sure this is the best way to do it.
As for validation of XML, I have found a great tool, xmlvalid, here:
<...
|
by: blurz |
last post by:
Hi,
would like to know how to go about validating a a group of textboxes. For
example, I have 3 textboxes that will hold a user's different contact
numbers. How do I ensure that at least one of the textboxes will be entered?
Solutions with syntax of coding will be appreciated. Thanks.
Rgrds,
blurz
|
by: Steve |
last post by:
I am currently trying to validate data in an access database. I need
to verify that columns containing date information are in the format
ddmmyyyy and columns containg time information are in the format HH:MM
24. The dates and times are stored in text fields. ie date 12121998,
time 20:34
Could anyone suggest a method for validating the fields. What is the
syntax for converting text fields into dates and times?
Any suggestions...
|
by: bildad |
last post by:
The following 'book example' of validating input seems to be incomplete.
Since it is a beginner's book it may be intentional for simplicity. But
I would like to know how to make this program work for all invalid
input. Just for example, if user inputs 'abc' an error is caught, but if
user inputs '432' the program hangs. Any clarification appreciated.
Thanks,
Bill
|
by: Alex Bink |
last post by:
Hi,
I have a validating event on a textbox in which I want to prevent the user
to leave the textbox without entering the right data. Only if he clicks on
another specific control he is allowed to leave the textbox without entering
the right information. Is there a way to determine which other control was
clicked in the validating event of the textbox?
Thanks
| |
by: Tom Anderson |
last post by:
Hi all,
A hoary old chestnut this - any advice on how to syntactically validate an
email address? I'd like to support both the display-name-and-angle-bracket
and bare-address forms, and to allow everything that RFC 2822 allows (and
nothing more!).
Currently, i've got some regexps which recognise a common subset of
possible addresses, but it would be nice to do this properly - i don't
currently support quoted pairs, quoted strings, or...
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first
set of examples, after decoding the HTML FORM contents, merely
verifies the text within a field to make sure it is a valid
representation of an integer, without any junk thrown in, i.e. it
must satisfy the regular expression: ^ *?+ *$
If the...
|
by: arunairs |
last post by:
Hi,
Is there a way of validating and XPath? In this case , I am
accepting an XPath from the user and I need to validate the XPath
syntax. Is there a regular expression available that anyone can
direct me to, to validate a XPath?
thanks,
Arun
|
by: Michael Stemper |
last post by:
The W3C Validator is a great help, as far as it goes. However, I'm looking
for something stricter. My coding style does not allow for implicit
termination of an element; my intention and desire is to explicitly
terminate every element.
Just last night, it took me two hours to track down some funny behavior. It
turned out to be caused by entries in a definition list that looked like:
<dt>Term<dt>
<dd>Definition</dd>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |