Analysis Device Parsing Context-Dependent Patterns
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Parsers for context-dependent patterns face significant time complexity issues, often requiring exponential time for data analysis, as seen in existing parsers using stateful packrat parsing.
Innovation Solution
The analysis device employs V-PEG (Parsing Expression Grammar with variable bindings) to perform parsing, where a variable is associated with a terminal symbol, and additional elements are added and extracted based on attributes, determining if they satisfy contextual conditions, thereby reducing parsing time.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If a parser uses stateful packrat parsing to analyze context-dependent patterns, then the parser can handle context-dependent grammar rules, but the analysis time increases exponentially with data size
Solution Approach 1:
The parser divides the context-dependent pattern matching into separate phases: first performing standard PEG parsing to build a parse tree, then separately analyzing context-dependent relationships using the parsed structure. This segmentation allows each phase to operate independently with optimized algorithms, avoiding exponential time complexity while maintaining context-dependent pattern handling capability.
Solution Approach 2:
The parser performs preliminary parsing using standard PEG rules before applying context-dependent analysis. By pre-processing the input data and establishing basic parse structures first, the system prepares the data in a form that enables efficient subsequent context-dependent analysis, preventing exponential time requirements.
2Adaptability or versatility
If a parser uses backtracking algorithm to handle complex patterns, then the parser can match complex grammar rules, but the processing time increases significantly
Solution Approach 1:
The invention extracts the backtracking operation from the main parsing flow and replaces it with deterministic PEG parsing followed by separate context analysis. This extraction eliminates unnecessary backtracking overhead while preserving the ability to match complex patterns through the two-phase approach.
Solution Approach 2:
The parser changes the operational parameters of the matching algorithm by switching from backtracking-based exploration to deterministic PEG matching with explicit context checks. This parameter change transforms the time complexity from exponential to polynomial while maintaining pattern matching capability.
Data Source
AI summary
An analysis device includes processing circuitry configured to perform parsing on a first character string based on a grammar described in a PEG in which a variable is associated with a predetermined terminal symbol, add, to the variable, an element in which a predetermined attribute is imparted to a part of the first character string, the part being a second character string analyzed as corresponding to the terminal symbol, extract an element that is latest from elements of each predetermined attribute from the variable, and determine whether the element extracted satisfies a predetermined condition regarding a context.


