aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Tools/c-analyzer/c_parser
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/c-analyzer/c_parser')
-rw-r--r--Tools/c-analyzer/c_parser/__main__.py4
-rw-r--r--Tools/c-analyzer/c_parser/_state_machine.py244
-rw-r--r--Tools/c-analyzer/c_parser/info.py3
-rw-r--r--Tools/c-analyzer/c_parser/parser/_alt.py6
-rw-r--r--Tools/c-analyzer/c_parser/parser/_delim.py54
-rw-r--r--Tools/c-analyzer/c_parser/parser/_global.py1
6 files changed, 1 insertions, 311 deletions
diff --git a/Tools/c-analyzer/c_parser/__main__.py b/Tools/c-analyzer/c_parser/__main__.py
index 78f47a1808f..2454fcba814 100644
--- a/Tools/c-analyzer/c_parser/__main__.py
+++ b/Tools/c-analyzer/c_parser/__main__.py
@@ -1,10 +1,7 @@
import logging
-import os.path
import sys
-from c_common import fsutil
from c_common.scriptutil import (
- CLIArgSpec as Arg,
add_verbosity_cli,
add_traceback_cli,
add_kind_filtering_cli,
@@ -15,7 +12,6 @@ from c_common.scriptutil import (
get_prog,
main_for_filenames,
)
-from .preprocessor import get_preprocessor
from .preprocessor.__main__ import (
add_common_cli as add_preprocessor_cli,
)
diff --git a/Tools/c-analyzer/c_parser/_state_machine.py b/Tools/c-analyzer/c_parser/_state_machine.py
deleted file mode 100644
index 875323188aa..00000000000
--- a/Tools/c-analyzer/c_parser/_state_machine.py
+++ /dev/null
@@ -1,244 +0,0 @@
-
-f'''
- struct {ANON_IDENTIFIER};
- struct {{ ... }}
- struct {IDENTIFIER} {{ ... }}
-
- union {ANON_IDENTIFIER};
- union {{ ... }}
- union {IDENTIFIER} {{ ... }}
-
- enum {ANON_IDENTIFIER};
- enum {{ ... }}
- enum {IDENTIFIER} {{ ... }}
-
- typedef {VARTYPE} {IDENTIFIER};
- typedef {IDENTIFIER};
- typedef {IDENTIFIER};
- typedef {IDENTIFIER};
-'''
-
-
-def parse(srclines):
- if isinstance(srclines, str): # a filename
- raise NotImplementedError
-
-
-
-# This only handles at most 10 nested levels.
-#MATCHED_PARENS = textwrap.dedent(rf'''
-# # matched parens
-# (?:
-# [(] # level 0
-# (?:
-# [^()]*
-# [(] # level 1
-# (?:
-# [^()]*
-# [(] # level 2
-# (?:
-# [^()]*
-# [(] # level 3
-# (?:
-# [^()]*
-# [(] # level 4
-# (?:
-# [^()]*
-# [(] # level 5
-# (?:
-# [^()]*
-# [(] # level 6
-# (?:
-# [^()]*
-# [(] # level 7
-# (?:
-# [^()]*
-# [(] # level 8
-# (?:
-# [^()]*
-# [(] # level 9
-# (?:
-# [^()]*
-# [(] # level 10
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )*
-# [^()]*
-# [)]
-# )
-# # end matched parens
-# ''')
-
-r'''
- # for loop
- (?:
- \s* \b for
- \s* [(]
- (
- [^;]* ;
- [^;]* ;
- .*?
- ) # <header>
- [)]
- \s*
- (?:
- (?:
- (
- {_ind(SIMPLE_STMT, 6)}
- ) # <stmt>
- ;
- )
- |
- ( {{ ) # <open>
- )
- )
- |
-
-
-
- (
- (?:
- (?:
- (?:
- {_ind(SIMPLE_STMT, 6)}
- )?
- return \b \s*
- {_ind(INITIALIZER, 5)}
- )
- |
- (?:
- (?:
- {IDENTIFIER} \s*
- (?: . | -> ) \s*
- )*
- {IDENTIFIER}
- \s* = \s*
- {_ind(INITIALIZER, 5)}
- )
- |
- (?:
- {_ind(SIMPLE_STMT, 5)}
- )
- )
- |
- # cast compound literal
- (?:
- (?:
- [^'"{{}};]*
- {_ind(STRING_LITERAL, 5)}
- )*
- [^'"{{}};]*?
- [^'"{{}};=]
- =
- \s* [(] [^)]* [)]
- \s* {{ [^;]* }}
- )
- ) # <stmt>
-
-
-
- # compound statement
- (?:
- (
- (?:
-
- # "for" statements are handled separately above.
- (?: (?: else \s+ )? if | switch | while ) \s*
- {_ind(COMPOUND_HEAD, 5)}
- )
- |
- (?: else | do )
- # We do not worry about compound statements for labels,
- # "case", or "default".
- )? # <header>
- \s*
- ( {{ ) # <open>
- )
-
-
-
- (
- (?:
- [^'"{{}};]*
- {_ind(STRING_LITERAL, 5)}
- )*
- [^'"{{}};]*
- # Presumably we will not see "== {{".
- [^\s='"{{}};]
- )? # <header>
-
-
-
- (
- \b
- (?:
- # We don't worry about labels with a compound statement.
- (?:
- switch \s* [(] [^{{]* [)]
- )
- |
- (?:
- case \b \s* [^:]+ [:]
- )
- |
- (?:
- default \s* [:]
- )
- |
- (?:
- do
- )
- |
- (?:
- while \s* [(] [^{{]* [)]
- )
- |
- #(?:
- # for \s* [(] [^{{]* [)]
- # )
- #|
- (?:
- if \s* [(]
- (?: [^{{]* [^)] \s* {{ )* [^{{]*
- [)]
- )
- |
- (?:
- else
- (?:
- \s*
- if \s* [(]
- (?: [^{{]* [^)] \s* {{ )* [^{{]*
- [)]
- )?
- )
- )
- )? # <header>
-'''
diff --git a/Tools/c-analyzer/c_parser/info.py b/Tools/c-analyzer/c_parser/info.py
index 3fa9fefbd5e..799f9237877 100644
--- a/Tools/c-analyzer/c_parser/info.py
+++ b/Tools/c-analyzer/c_parser/info.py
@@ -1,6 +1,5 @@
from collections import namedtuple
import enum
-import os.path
import re
from c_common import fsutil
@@ -8,7 +7,7 @@ from c_common.clsutil import classonly
import c_common.misc as _misc
import c_common.strutil as _strutil
import c_common.tables as _tables
-from .parser._regexes import SIMPLE_TYPE, _STORAGE
+from .parser._regexes import _STORAGE
FIXED_TYPE = _misc.Labeled('FIXED_TYPE')
diff --git a/Tools/c-analyzer/c_parser/parser/_alt.py b/Tools/c-analyzer/c_parser/parser/_alt.py
deleted file mode 100644
index 05a9101b4f5..00000000000
--- a/Tools/c-analyzer/c_parser/parser/_alt.py
+++ /dev/null
@@ -1,6 +0,0 @@
-
-def _parse(srclines, anon_name):
- text = ' '.join(l for _, l in srclines)
-
- from ._delim import parse
- yield from parse(text, anon_name)
diff --git a/Tools/c-analyzer/c_parser/parser/_delim.py b/Tools/c-analyzer/c_parser/parser/_delim.py
deleted file mode 100644
index 51433a629d3..00000000000
--- a/Tools/c-analyzer/c_parser/parser/_delim.py
+++ /dev/null
@@ -1,54 +0,0 @@
-import re
-import textwrap
-
-from ._regexes import _ind, STRING_LITERAL
-
-
-def parse(text, anon_name):
- context = None
- data = None
- for m in DELIMITER_RE.find_iter(text):
- before, opened, closed = m.groups()
- delim = opened or closed
-
- handle_segment = HANDLERS[context][delim]
- result, context, data = handle_segment(before, delim, data)
- if result:
- yield result
-
-
-DELIMITER = textwrap.dedent(rf'''
- (
- (?:
- [^'"()\[\]{};]*
- {_ind(STRING_LITERAL, 3)}
- }*
- [^'"()\[\]{};]+
- )? # <before>
- (?:
- (
- [(\[{]
- ) # <open>
- |
- (
- [)\]};]
- ) # <close>
- )?
- ''')
-DELIMITER_RE = re.compile(DELIMITER, re.VERBOSE)
-
-_HANDLERS = {
- None: { # global
- # opened
- '{': ...,
- '[': None,
- '(': None,
- # closed
- '}': None,
- ']': None,
- ')': None,
- ';': ...,
- },
- '': {
- },
-}
diff --git a/Tools/c-analyzer/c_parser/parser/_global.py b/Tools/c-analyzer/c_parser/parser/_global.py
index 35947c12998..b1ac9f5db03 100644
--- a/Tools/c-analyzer/c_parser/parser/_global.py
+++ b/Tools/c-analyzer/c_parser/parser/_global.py
@@ -9,7 +9,6 @@ from ._common import (
set_capture_groups,
)
from ._compound_decl_body import DECL_BODY_PARSERS
-#from ._func_body import parse_function_body
from ._func_body import parse_function_statics as parse_function_body