Commit Graph

37 Commits

Author SHA1 Message Date
Miro Hrončok
cbb61fb819 Relax a test regex to match new enum repr in Python 3.10.0a7+ (#186)
bpo-40066: Enum: adjust repr() to show only enum and member name (not value,
nor angle brackets) and str() to show only member name.
https://bugs.python.org/issue40066
2021-04-22 12:04:49 -07:00
Dave Halter
6eb6ac0bb2 Ignore Python 2 specific code in tests 2020-07-25 01:41:33 +02:00
Dave Halter
19f4550ced Use enum instead of our own logic 2020-07-24 17:39:49 +02:00
Dave Halter
2962517be0 Get rid of the xfails 2020-07-24 15:43:41 +02:00
Dave Halter
93e74efc01 Some whitespace changes 2020-07-24 14:50:01 +02:00
Dave Halter
b5e2e67a4d Remove support for parsing Python 2 2020-07-24 14:48:02 +02:00
Dave Halter
164489cf97 Remove the u function and u literals 2020-07-24 01:39:03 +02:00
Jocelyn Boullier
88874a5a9f Fix #139: newlines in async for comprehension 2020-06-29 18:40:55 +02:00
Dave Halter
734a4b0e67 Remove support for specialized treatment of form feeds
This is a very intentional change. Previously form feeds were handled very
poorly and sometimes where not counted as indentation. This obviously makes
sense. But at the same time indentation is very tricky to deal with (both for
editors and parso).

Especially in the diff parser this led to a lot of very weird issues. The
decision probably makes sense since:

1. Almost nobody uses form feeds in the first place.
2. People that use form feeds like Barry Warsaw often put a newline ater them.
   (e.g Python's email.__init__)
3. If you write an editor you want to be able to identify a unicode character
   with a clear line/column. This would not be the case if form feeds were just
   ignored when counting.

Form feeds will still work in Jedi, will not cause parse errors and in general
you should be fine using them. It might just cause Jedi to count them as
indentation **if** you use it like '\f  foo()'. This is however confusing for
most editors anyway. It leads to a weird display e.g. in VIM, even if it's
perfectly valid code in Python.

Since parso is a code analysis parser and not the languages parser I think it's
fine to ignore this edge case.
2020-04-04 15:38:10 +02:00
Dave Halter
e723b3e74b Refactor the ambiguity tests a bit, see #70 2019-07-13 20:15:56 +02:00
Benjamin Woodruff
0032bae041 Make pgen2's grammar ambiguity detection handle more cases
Under the old implementation,

```
outer: A [inner] B C
inner: B C [inner]
```

wouldn't get detected as the ambiguous grammar that it is, whereas

```
outer: A rest
rest: [inner] B C
inner: B C [inner]
```

would.

This would manifest itself as non-determinism in the DFA state
generation. See the discussion #62 on for a full explanation.

This modifies the ambiguity detection to work on a broader class of
issues, so it should now hopefully detect all cases where the given
grammar is ambiguous.

At some point, we could extend this logic to allow developers to
optionally set precedence of grammar productions, which could resolve
ambiguities, but that's not a strict requirement for parsing python.
2019-07-13 20:04:32 +02:00
prim
93ddf5322a parse long number notation (#72)
* parse long number notation

* parse long number notation
2019-06-02 11:14:15 +02:00
Dave Halter
f66e47c540 Check better for more transitions 2018-06-26 22:53:02 +02:00
Dave Halter
e20f2069ba Move the grammar to a fitting file. 2018-06-26 10:20:05 +02:00
Dave Halter
a46ecbb499 Fix an ambiguity issue
Unfortunately had to refactor most of the transition generation
2018-06-26 00:58:19 +02:00
Dave Halter
da5aa8a2ab Better detection of ambiguities 2018-06-25 01:56:02 +02:00
Dave Halter
fa0bf4951c Fix string prefixes for Python2. 2017-09-01 00:20:24 +02:00
Dave Halter
db1079a7fe Actual support fo backticks. 2017-08-28 18:32:48 +02:00
Dave Halter
476d5fb0d1 Some Python2.7 fixes. 2017-08-15 19:34:47 +02:00
Dave Halter
d6c624bd34 Finally fix Python 2.6.
Also added a syntax for 2.6. There are some thing that just don't work in 2.6.
2017-07-31 21:33:59 +02:00
Dave Halter
a13f1a18a9 A dict unpacking test. 2017-07-23 19:55:05 +02:00
Dave Halter
1ed3cac7c0 Move some things around to allow checking for different versions. 2017-07-22 15:47:04 +02:00
Dave Halter
5e65bd2aaf Remove xfail tests that didn't make any sense. 2017-07-19 18:15:23 +02:00
Dave Halter
78c371f73a Refactor the version info to use a tuple, always. 2017-07-19 09:09:33 +02:00
Dave Halter
688dfaad24 Make ellipsis work for the differences between 2 and 3. 2017-07-16 18:49:19 +02:00
Dave Halter
b618c99b08 Octal fixes. 2017-07-12 22:28:54 +02:00
Dave Halter
70de06ed87 Fix annotations in grammar2.7. 2017-07-12 21:38:11 +02:00
Dave Halter
d7d1d67828 Refactor some tests to make sure cross parsing versions works. 2017-07-12 21:32:16 +02:00
Dave Halter
abc4852bd4 Write an abstraction to test if source code is valid for a certain python version or not. 2017-07-12 18:58:43 +02:00
Dave Halter
d3115acb33 Refactor a parse call. 2017-07-12 10:03:48 +02:00
Dave Halter
75d41c09cd Trying to run more tests in all versions against all versions. 2017-07-12 09:37:47 +02:00
Dave Halter
333046c253 load_python_grammar -> load_grammar. 2017-05-25 13:28:24 -04:00
Dave Halter
7d3438c94d Move the parse function to the grammar. 2017-05-22 14:06:40 -04:00
Dave Halter
23d1470618 Add a more API focused grammar.
This makes it so we don't have to expose all the details of a pgen grammar to the user.
2017-05-21 17:02:15 -04:00
Dave Halter
799e99360c Remove the dependency to unittest. 2017-05-17 14:29:55 -04:00
Dave Halter
206dfd113b Use jedi less in the tests. 2017-05-15 13:53:30 -04:00
Dave Halter
7445c303e3 A test suite imported from jedi. 2017-05-11 09:43:37 -04:00