Multiphase single pass interpreter
First Claim
Patent Images
1. A method of interpreting a code, comprising:
- scanning a stream of characters;
converting the scanned stream of characters into a stream of tokens, if the stream of characters represent a start tag of a script;
if the stream of characters represent a start tag of a script, lexing, parsing, and executing one or more streams of characters following the start tag;
if the one or more streams of characters represent a control logic block, generating p-code associated with one or more streams of characters within the control logic block and executing the generated p-code; and
repeating the lexing, parsing, and executing step and the generating p-code step until a token representing a stop tag of the script is detected.
0 Assignments
0 Petitions
Accused Products
Abstract
A multiphase single pass interpreter switches modes of execution. The interpreter scans a program file in a scan phase until a tag signaling the presence of a script language is encountered. The interpreter then switches its mode to full parse phase where each line scanned is tokenized and parsed. Tokens are replaced with their dynamic content, if any. When the interpreter detects logic blocks, the interpreter changes its mode to p-code generation phase and generates p-code for the lines of code within the logic block. The generated p-code is then executed by the interpreter in its p-code execution phase. The interpretation is performed in a single pass through the program file.
37 Citations
15 Claims
-
1. A method of interpreting a code, comprising:
-
scanning a stream of characters;
converting the scanned stream of characters into a stream of tokens, if the stream of characters represent a start tag of a script;
if the stream of characters represent a start tag of a script, lexing, parsing, and executing one or more streams of characters following the start tag;
if the one or more streams of characters represent a control logic block, generating p-code associated with one or more streams of characters within the control logic block and executing the generated p-code; and
repeating the lexing, parsing, and executing step and the generating p-code step until a token representing a stop tag of the script is detected. - View Dependent Claims (2, 3, 15)
dynamically replacing the stream of characters with associated dynamic content, if the stream of characters are determined to contain a symbol having dynamic content.
-
-
3. The method of claim 1, further including:
transmitting the scanned stream of characters to a standard output stream after the step of scanning a stream of characters in a code if the start tag is not detected.
-
15. The method of claim 2, wherein the stream of characters represent one or more script objects.
-
4. A multiphase single pass interpreter tangibly embodied on a computer readable medium, comprising:
-
a lexical analyzer to receive a character stream and to convert the character stream into a token, if the stream of characters represent a start tag of a script;
a parser to receive one or more of the tokens from the lexical analyzer;
a p-code generator to receive the one or more of the parsed tokens to generate p-code associated with the one or more of the parsed tokens; and
an executor to execute the generated p-code, wherein the lexical analyzer, the parser, the p-code generator, and the executor switch functioning phases during a single pass through a script. - View Dependent Claims (5, 6)
-
-
7. A method of interpreting a code, comprising:
-
scanning one or more characters of a code, in a scan phase;
if a script start tag is scanned, converting the scanned stream of characters into a stream of tokens, switching to a full parse phase to fully lexan, parse, and execute one or more instructions following the start tag;
if a conditional block is scanned following the start tag, switching to p-code generation phase to generate p-code for one or more instructions within the conditional block, and switching to p-code execution phase to execute the p-code. - View Dependent Claims (8, 9)
dynamically replacing the one or more characters with associated dynamic content, if it is determined that the one or more characters has dynamic content.
-
-
9. The method of interpreting a code as claimed in claim 7, further including:
transmitting the one or more scanned characters to a standard output stream.
-
10. A program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps of interpreting a code, comprising:
-
scanning a stream of characters;
converting the scanned stream of characters into a stream of tokens, if the stream of characters represent a start tag of a script;
if the stream of characters represent a start tag of a script, lexing, parsing, and executing one or more streams of characters following the start tag;
if the one or more streams of characters represent a control logic block, generating p-code associated with one or more streams of characters within the control logic block and executing the generated p-code; and
repeating the lexing, parsing, and executing step and the generating p-code step until a token representing a stop tag of the script is detected. - View Dependent Claims (11)
dynamically replacing the stream of characters with associated dynamic content, if the stream of characters are determined to contain a symbol having dynamic content.
-
-
12. A program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps of interpreting a code, comprising:
-
scanning one or more characters from a code, in a scan phase;
if a script start tag is scanned, converting the scanned stream of characters into a stream of tokens, switching to a full parse phase to fully scan, parse, and execute one or more instructions following the start tag;
if a conditional block is scanned following the start tag, switching to a p-code generation phase to generate p-code for one or more instruction within the conditional block, and switching to a p-code execution phase to execute the p-code. - View Dependent Claims (13, 14)
if a script stop tag is scanned, switching back to the scan phase.
-
-
14. The program storage device of claim 12, further including, if an end of file is detected:
-
switching to a termination phase;
releasing one or more resources; and
flushing buffers.
-
Specification