Indentation-Based Source Code Structure Inference for Partial Parsing

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional source code parsers face challenges when dealing with multiple programming languages, partially completed code, and human-interactive environments that require responsiveness, as they rely on strict grammar rules and are computationally inefficient.

Innovation Solution

A partial parser that infers source code structure based on indentation, generating a code structure tree that captures overall structure quickly and efficiently, even with incomplete or erroneous code, by using indentation levels and common syntax refinement.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If conventional source code parsers are used to parse source code, then accurate syntactic analysis is achieved, but significant computing resources are required and responsiveness is reduced

Engineering Contradiction:
Improvesyntactic analysis accuracyVSAvoidcomputing resources
Core Design Contradiction:
Measurement precisionVSUse of energy by moving object

Solution Approach 1:

The patent applies partial parsing by using indentation information rather than complete syntactic parsing. The system identifies code structure and relationships based solely on indentation levels, skipping the computationally intensive full parsing process while still achieving sufficient accuracy for the intended applications like code navigation and manipulation.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent extracts only the essential indentation information from source code, separating this key structural feature from the rest of the syntactic analysis. By focusing exclusively on indentation patterns, the system obtains sufficient structural understanding without the computational overhead of complete parsing.

Inventive Principle:
Principle #2Taking out (Extraction)

2Measurement precision

If conventional source code parsers are used to parse source code, then accurate syntactic analysis is achieved, but the system becomes slower and less responsive

Engineering Contradiction:
Improvesyntactic analysis accuracyVSAvoidparsing speed
Core Design Contradiction:
Measurement precisionVSSpeed

Solution Approach 1:

The system performs partial parsing by relying on indentation patterns rather than complete syntactic analysis. This approach dramatically reduces processing time while maintaining sufficient accuracy for code structure understanding, enabling responsive user interactions in human-interactive environments.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent extracts and processes only indentation information, filtering out the computationally heavy aspects of full syntactic parsing. This selective extraction maintains the essential structural understanding needed for code manipulation while achieving fast processing speeds.

Inventive Principle:
Principle #2Taking out (Extraction)

3Measurement precision

If conventional source code parsers are used, then complete syntactic analysis is achieved, but handling of partially completed code becomes difficult

Engineering Contradiction:
Improvesyntactic analysis accuracyVSAvoidhandling incomplete code
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The system is designed for partial parsing that works effectively with incomplete code. By focusing on indentation patterns rather than complete syntactic rules, the parser can successfully analyze partially completed code structures, making it adaptable to code in various states of completion.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent changes the parsing approach from syntax-rule-based to indentation-based parameter analysis. This parameter change enables the system to handle incomplete code gracefully, as indentation patterns remain meaningful even when code is partially written or contains errors.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentEP4544397B1Source code structural inference based on indentation
Publication Date: 2026.04.22 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP4544397B1 patent drawingFigure 1
  • EP4544397B1 patent drawingFigure 2
  • EP4544397B1 patent drawingFigure 3

AI summary

Inferring source code structure based on indentation. A portion of source code comprising a plurality of lines is identified, and a corresponding indentation level for each line is determined. A plurality of nodes, each representing a different line in the plurality of lines are generated. The nodes are arranged into an ordered tree based on the corresponding indentation level for each line. Based on an identified line in the plurality of lines, a subset of the plurality of lines are identified from the ordered tree, based on identifying a subtree that comprises a node representing the identified line. A source code action is initiated based on the subset of the plurality of lines.