IP Library › Granted Patent US 12,541,350
Granted Patent B2
US 12,541,350 · App. 18/252,232 · Granted Feb 3, 2026

Method and device for parsing programming language, and non-transitory computer-readable storage medium

Inventors: Ruo Li (Beijing, CN); Tiao Lu (Beijing, CN)
Assignees: PEKING UNIVERSITY; PEKING UNIVERSITY CHONGQING RESEARCH INSTITUTE OF BIG DATA
G06F8/425G06F8/31G06F8/427
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,541,350
App. No.
18/252,232
Granted
Feb 3, 2026
Kind
B2
Abstract

The embodiments of the disclosure disclose a method and device for parsing a programming language, and a non-transitory computer-readable storage medium. The method includes that: a source code is converted as a character stream, and the character stream is parsed into a lexical unit list, the lexical unit list including a plurality of lexical units; the plurality of lexical units are classified into a first-type lexical unit and a second-type lexical unit, the first-type lexical unit being a lexical unit including an ambiguous token, and the second-type lexical unit being a lexical unit not including the ambiguous token; the first-type lexical unit is converted into the second-type lexical unit; and the second-type lexical unit converted from the first-type lexical unit and the second-type lexical unit classified from the plurality of lexical units are parsed.

Claims (23)

1 . A method for parsing a programming language, comprising:

converting a source code into a character stream, and parsing the character stream into a lexical unit list, wherein the lexical unit list comprises a plurality of lexical units;

classifying the plurality of lexical units into a first-type lexical unit and a second-type lexical unit, wherein the first-type lexical unit is a lexical unit comprising an ambiguous token, the second-type lexical unit being a lexical unit not comprising the ambiguous token;

converting the first-type lexical unit into the second-type lexical unit; and

parsing the second-type lexical unit converted from the first-type lexical unit and the second-type lexical unit classified from the plurality of lexical units,

wherein parsing the character stream into the lexical unit list comprises:

parsing the character stream into the lexical unit list according to a preset word formation rule, wherein each lexical unit in the lexical unit list comprises: a token-name and an attribute-value, the token-name being the symbol of the lexical unit itself, and the attribute-value being the type of the lexical unit.

2 . The method as claimed in claim 1 , wherein classifying the plurality of lexical units into the first-type lexical unit and the second-type lexical unit comprises:

acquiring token-names of the plurality of lexical units;

determining an ambiguous target token-name from the token-names; and

determining the lexical unit to which the target token-name belongs as the first-type lexical unit, and determining the lexical unit to which the token-names except the target token-name belong as the second-type lexical unit.

3 . The method as claimed in claim 1 , wherein

converting the first-type lexical unit into the second-type lexical unit comprises: inputting the first-type lexical unit into a semantic analyzer for parsing to obtain the second-type lexical unit;

wherein parsing the second-type lexical unit converted from the first-type lexical unit and the second-type lexical unit classified from the plurality of lexical units comprises: inputting the second-type lexical unit converted from the first-type lexical unit and the second-type lexical unit classified from the plurality of lexical units into a syntactic analyzer for parsing; and inputting a parsing result of the second-type lexical unit by the syntactic analyzer to the semantic analyzer for parsing.

4 . The method as claimed in claim 3 , wherein inputting the first-type lexical unit into the semantic analyzer for parsing to obtain the second-type lexical unit comprises:

determining a type of the token-name of the first-type lexical unit according to context information of the first-type lexical unit; and

modifying an attribute-value of the first-type lexical unit according to the type of the token-name of the first-type lexical unit to obtain the second-type lexical unit.

5 . The method as claimed in claim 3 , wherein inputting the second-type lexical unit converted from the first-type lexical unit and the second-type lexical unit classified from the plurality of lexical units into the syntactic analyzer for parsing comprises:

assembling the second-type lexical unit converted from the first-type lexical unit and the second-type lexical unit classified from the plurality of lexical units into a syntax analysis tree.

6 . The method as claimed in claim 5 , wherein inputting the parsing result of the second-type lexical unit by the syntactic analyzer to the semantic analyzer for parsing comprises:

performing simplifying processing on the syntax analysis tree to construct an abstract syntax tree.

7 . A non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium comprising a stored program, wherein when the program runs, a device where the non-transitory computer-readable storage medium is located is controlled to execute the method for parsing the programming language as claimed in claim 1 .

8 . A processor, the processor being configured to run a program stored in a memory, wherein when running, the program executes the method for parsing the programming language as claimed in claim 1 .

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 12, 2025
From: LI, RUO; LU, TIAO
To: PEKING UNIVERSITY; PEKING UNIVERSITY CHONGQING RESEARCH INSTITUTE OF BIG DATA
Reel/Frame 072877/0745 →
Priority Claims (1)
CN 202210063667.0 · Jan 20, 2022 · national
Continuity (1)
Related Publication 20250199779A1 · Jun 19, 2025
References Cited (21)
US 8943472B1 · Ganelin · 2015 [cited by applicant]
US 11061652B1 · Biswas · 2021 [cited by examiner]
US 20100088674A1 · Della-Libera · 2010 [cited by applicant]
US 20130055223A1 · Xu · 2013 [cited by examiner]
US 20170024193A1 · Goubier · 2017 [cited by applicant]
US 20170242842A1 · Halbani · 2017 [cited by examiner]
US 20180081870A1 · Zelenkov · 2018 [cited by examiner]
US 20200097389A1 · Smith · 2020 [cited by examiner]
CN 106033394A · 2016 [cited by applicant]
CN 110221836A · 2019 [cited by applicant]
CN 110673854A · 2020 [cited by applicant]
CN 111309757A · 2020 [cited by applicant]
CN 113741869A · 2021 [cited by applicant]
CN 114090017A · 2022 [cited by applicant]
JP H05241850A · 1993 [cited by applicant]
WO 2015006075A1 · 2015 [cited by applicant]
Begel, et al., “Language Analysis and Tools for Ambiguous Input Streams”, Electronic Notes in Theoretical Computer Science 110 (2004) 75-96. [cited by applicant]
Joisha, et al., “Handling Context-Sensitive Syntactic Issues in the Design of a Front-end for a MATLAB Compiler”, Supplement to the APL Berlin 2000 Proceedings, Jul. 24, 2000. [cited by applicant]
Malloy, et al, “Decorating tokens to facilitate recognition of ambiguous language constructs”, Softw. Pract. Exper. 2003; 33:19-39 (Nov. 12, 2002). [cited by applicant]
Q. Pan, et al.: “Design and optimization of SCPI command interpreter based on Python,” Industrial Control Computer 33 (2020) 75. [cited by applicant]
The first office action of counterpart JP application No. 2024-540883 was issued on May 20, 2025. [cited by applicant]