Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Live long and prosper. -- Spock, "Amok Time", stardate 3372.7


devel / comp.lang.python / Re: What to use for finding as many syntax errors as possible.

SubjectAuthor
o Re: What to use for finding as many syntax errors as possible.Peter J. Holzer

1
Re: What to use for finding as many syntax errors as possible.

<mailman.690.1665620065.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19877&group=comp.lang.python#19877

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-pyt...@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: What to use for finding as many syntax errors as possible.
Date: Thu, 13 Oct 2022 02:14:23 +0200
Lines: 72
Message-ID: <mailman.690.1665620065.20444.python-list@python.org>
References: <CAPTjJmrvVqpX8+bcH_2P8xr8c4=CSBK9vP9QkpxS5zxqkeObyg@mail.gmail.com>
<Y0SZ6coJzhm6jc1B@cskk.homeip.net>
<CAPTjJmr9KKZWx9oCWXYMVVwDp5t-xr38KuvcM33iWueadSYSOQ@mail.gmail.com>
<20221013001423.kemxsamwqqr3yfl6@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="akikzeibwk6olnfy"
X-Trace: news.uni-berlin.de QehK9AK6W1YWccCnnxHKjQwdhgAqynptfpiUsYCFhrXw==
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; '2022':
0.05; 'content-type:multipart/signed': 0.05; 'angelico': 0.09;
'content-type:application/pgp-signature': 0.09; 'else:': 0.09;
'filename:fname piece:asc': 0.09; 'filename:fname
piece:signature': 0.09; 'filename:fname:signature.asc': 0.09;
'token': 0.09; 'syntax': 0.15; 'that.': 0.15; '"creative': 0.16;
'+1100,': 0.16; '__/': 0.16; 'cameron': 0.16; 'challenge!"': 0.16;
'colon': 0.16; 'complaints,': 0.16; 'fixes': 0.16; 'from:addr:hjp-
python': 0.16; 'from:addr:hjp.at': 0.16; 'from:name:peter j.
holzer': 0.16; 'hjp@hjp.at': 0.16; 'holzer': 0.16; 'impossible':
0.16; 'parsing': 0.16; 'reality.': 0.16; 'right.': 0.16;
'seconds.': 0.16; 'simpson': 0.16; 'sort.': 0.16; 'stross,': 0.16;
'subject:syntax': 0.16; 'syntactic': 0.16; 'url-
ip:212.17.106.137/32': 0.16; 'url-ip:212.17.106/24': 0.16; 'url-
ip:212.17/16': 0.16; 'url:hjp': 0.16; '|_|_)': 0.16; 'wrote:':
0.16; 'python': 0.16; 'tue,': 0.19; 'to:addr:python-list': 0.20;
'doubt': 0.22; 'code': 0.23; 'chris': 0.28; 'sense': 0.28;
'error': 0.29; "doesn't": 0.32; 'guess': 0.32; 'subject:for':
0.33; 'hold': 0.33; "didn't": 0.34; 'header:In-Reply-To:1': 0.34;
'majority': 0.35; 'one.': 0.35; 'particularly': 0.35; 'yes,':
0.35; 'errors': 0.36; 'missing': 0.37; 'special': 0.37; 'really':
0.37; "it's": 0.37; 'read': 0.38; 'least': 0.39; 'single': 0.39;
'seconds': 0.40; 'subject:What': 0.40; 'try': 0.40; 'should':
0.40; 'skip:h 10': 0.61; 'received:212': 0.62; 'produce': 0.65;
'years': 0.65; 'received:userid': 0.66; 'manner': 0.69; 'papers':
0.69; 'productivity': 0.69; 'url-ip:212/8': 0.69; 'vast': 0.69;
'combination': 0.76; 'discover': 0.80; 'strategy': 0.84; '0.1':
0.84; 'cost,': 0.84; 'grammar,': 0.84; 'grew': 0.84;
'received:at': 0.84; 'subject:many': 0.84; 'two.': 0.91
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <CAPTjJmr9KKZWx9oCWXYMVVwDp5t-xr38KuvcM33iWueadSYSOQ@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20221013001423.kemxsamwqqr3yfl6@hjp.at>
X-Mailman-Original-References: <CAPTjJmrvVqpX8+bcH_2P8xr8c4=CSBK9vP9QkpxS5zxqkeObyg@mail.gmail.com>
<Y0SZ6coJzhm6jc1B@cskk.homeip.net>
<CAPTjJmr9KKZWx9oCWXYMVVwDp5t-xr38KuvcM33iWueadSYSOQ@mail.gmail.com>
 by: Peter J. Holzer - Thu, 13 Oct 2022 00:14 UTC
Attachments: signature.asc (application/pgp-signature)

On 2022-10-11 09:47:52 +1100, Chris Angelico wrote:
> On Tue, 11 Oct 2022 at 09:18, Cameron Simpson <cs@cskk.id.au> wrote:
> >
> Consider:
>
> if condition # no colon
> code
> else:
> code
>
> To actually "restart" parsing, you have to make a guess of some sort.

Right. At least one of the papers on parsing I read over the last few
years (yeah, I really should try to find them again) argued that the
vast majority of syntax errors is either a missing token, a superfluous
token or a combination of the the two. So one strategy with good results
is to heuristically try to insert or delete single tokens and check
which results in the longest distance to the next error.

Checking multiple possible fixes has its cost, especially since you have
to do that at every error. So you can argue that it is better for
productivity if you discover one error in 0.1 seconds than 10 errors in
5 seconds.

> > I grew up with C and Pascal compilers which would _happily_ produce many
> > complaints, usually accurate, and all manner of syntactic errors. They
> > didn't stop at the first syntax error.
>
> Yes, because they work with a much simpler grammar.

I very much doubt that. Python doesn't have a particularly complicated
grammar, and C certainly doesn't have a particularly simple one.

The argument that it's impossible in Python (unlike any other language),
because Python is oh so special doesn't hold water.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)
1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor