Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/libcst/_parser/whitespace_parser.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-25 06:43 +0000

1# Copyright (c) Meta Platforms, Inc. and affiliates. 

2# 

3# This source code is licensed under the MIT license found in the 

4# LICENSE file in the root directory of this source tree. 

5 

6""" 

7Parso doesn't attempt to parse (or even emit tokens for) whitespace or comments that 

8aren't syntatically important. Instead, we're just given the whitespace as a "prefix" of 

9the token. 

10 

11However, in our CST, whitespace is gathered into far more detailed objects than a simple 

12str. 

13 

14Fortunately this isn't hard for us to parse ourselves, so we just use our own 

15hand-rolled recursive descent parser. 

16""" 

17 

18try: 

19 # It'd be better to do `from libcst_native.whitespace_parser import *`, but we're 

20 # blocked on https://github.com/PyO3/pyo3/issues/759 

21 # (which ultimately seems to be a limitation of how importlib works) 

22 from libcst_native import whitespace_parser as mod 

23except ImportError: 

24 from libcst._parser import py_whitespace_parser as mod 

25 

26parse_simple_whitespace = mod.parse_simple_whitespace 

27parse_empty_lines = mod.parse_empty_lines 

28parse_trailing_whitespace = mod.parse_trailing_whitespace 

29parse_parenthesizable_whitespace = mod.parse_parenthesizable_whitespace