JP2868127B2 - Blank reading device in lexical analysis - Google Patents
Blank reading device in lexical analysisInfo
- Publication number
- JP2868127B2 JP2868127B2 JP32667389A JP32667389A JP2868127B2 JP 2868127 B2 JP2868127 B2 JP 2868127B2 JP 32667389 A JP32667389 A JP 32667389A JP 32667389 A JP32667389 A JP 32667389A JP 2868127 B2 JP2868127 B2 JP 2868127B2
- Authority
- JP
- Japan
- Prior art keywords
- bytes
- blank
- lexical analysis
- source program
- byte
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Landscapes
- Devices For Executing Special Programs (AREA)
Description
【発明の詳細な説明】 〔概要〕 字句解析における空白読み飛ばし装置に関し、システ
ムが持つ複数バイトを一度に比較演算する比較演算機能
を用い、ソースプログラムから複数バイト単位(例えば
整数型データの4バイト単位)に空白を判定して読み飛
ばし、空白の読み飛ばし処理のための比較演算回数を削
減して字句解析処理を高速に実行することを目的とし、 システムが持つ複数バイトを一度に比較演算する比較
演算機能を用い、ソースプログラムから取り出した複数
バイト分の文字列のコードと、複数バイト分の空白コー
ドとの排他的論理和演算を行い、先頭からその結果が0
(零)のバイト数だけ空白と判定して読み飛ばし、字句
の取り出し・解析を行うように構成する。DETAILED DESCRIPTION OF THE INVENTION [Overview] Regarding a blank reading device in lexical analysis, a comparison operation function for comparing a plurality of bytes of the system at a time is used, and a plurality of bytes (for example, 4 bytes of integer type data) are obtained from a source program by a source program. The purpose of the system is to compare and calculate multiple bytes at a time with the aim of reducing the number of comparison operations for skipping white space and performing high-speed lexical analysis processing. Using a comparison operation function, an exclusive OR operation is performed on a character string code for a plurality of bytes extracted from the source program and a blank code for a plurality of bytes, and the result is 0 from the beginning.
The system is configured so that it is determined that the number of bytes of (zero) is blank and skips reading, and lexical extraction and analysis are performed.
本発明は、字句解析における空白読み飛ばし装置に関
するものである。The present invention relates to a blank reading device in lexical analysis.
〔従来の技術と発明が解決しようとする課題〕 FORTRAN言語で記述したソースプログラム中の空白
は、注釈および文字定数内を除いて意味がない。例えば
英字名ABCがある場合、 REAL ABC ・・・・・(1) REAL A B C ・・(2) の両者は同じ意味である。このため、FORTRAN処理系に
おける字句解析では、空白文字の読み飛ばし処理が非常
に重要な意味を持っている。[Problems to be Solved by the Prior Art and the Invention] White space in a source program described in FORTRAN language has no meaning except in comments and character constants. For example, if there is an alphabet name ABC, both REAL ABC... (1) REAL ABC... (2) have the same meaning. For this reason, in lexical analysis in the FORTRAN processing system, the processing of skipping blank characters has a very important meaning.
従来、字句解析時に、空白文字の読み飛ばし処理は、
1文字毎(1バイト毎)に空白か否かを調べながら走査
していた。このため、FORTRANソースプログラムに空白
の数が多くなるに従い、字句解析の処理時間が長くなっ
てしまうという問題があった。Conventionally, at the time of lexical analysis, the process of skipping blank characters
Scanning was performed while checking for blanks for each character (every byte). For this reason, there is a problem that the processing time of the lexical analysis becomes longer as the number of blanks increases in the FORTRAN source program.
本発明は、システムが持つ複数バイトを一度に比較演
算する比較演算機能を用い、ソースプログラムから複数
バイト単位(例えば整数型データの4バイト単位)に空
白を判定して読み飛ばし、空白の読み飛ばし処理のため
の比較演算回数を削減して字句解析処理を高速に実行す
ることを目的としている。The present invention uses a comparison operation function for comparing a plurality of bytes of a system at a time, and determines and skips blanks in a plurality of bytes (for example, 4 bytes of integer type data) from a source program, and skips blanks. An object of the present invention is to execute the lexical analysis processing at high speed by reducing the number of comparison operations for the processing.
第1図を参照して課題を解決する手段を説明する。 Means for solving the problem will be described with reference to FIG.
第1図において、ソースプログラム1は、読み飛ばし
て字句解析を行う対象のソースプログラムである。In FIG. 1, a source program 1 is a source program to be skipped and subjected to lexical analysis.
比較演算機能2は、システムが持つ複数バイトを一度
に比較演算する比較演算機能である。The comparison operation function 2 is a comparison operation function that performs a comparison operation on a plurality of bytes of the system at a time.
本発明は、第1図に示すように、システムが持つ複数
バイトを一度に比較演算する比較演算機能2を用い、ソ
ースプログラム1から取り出した複数バイト分の文字列
のコードと、複数バイト分の空白コードとの排他的論理
和演算を行い、先頭からその結果が0(零)のバイト数
だけ空白と判定して読み飛ばし、字句の取り出し・解析
を行うようにしている。As shown in FIG. 1, the present invention uses a comparison operation function 2 for comparing and operating a plurality of bytes of the system at a time. An exclusive-OR operation with a blank code is performed, and the result is determined to be blank by the number of 0 (zero) bytes from the beginning, skipped, and lexical extraction and analysis are performed.
従って、システムが持つ比較演算機能2を用い、ソー
スプログラム1から複数バイト単位(例えば整数型デー
タの4バイト単位)に空白を判定して読み飛ばすことに
より、空白の涜み飛ばし処理のための比較演算回数を削
減して字句解析処理を高速に実行することが可能とな
る。Therefore, by using the comparison operation function 2 of the system and determining and skipping blanks from the source program 1 in units of a plurality of bytes (for example, in units of 4 bytes of integer-type data), the comparison for blank blasphemy removal processing is performed. The lexical analysis process can be executed at high speed by reducing the number of operations.
次に、第1図および第2図を用いて本発明の1実施例
の構成および動作を順次詳細に説明する。Next, the configuration and operation of one embodiment of the present invention will be sequentially described in detail with reference to FIG. 1 and FIG.
第1図において、ソースプログラム1は、読み飛ばし
て字句解析を行う対象のFORTRAN言語で記述したソース
プログラムである。In FIG. 1, a source program 1 is a source program described in a FORTRAN language to be skipped and subjected to lexical analysis.
比較演算機能2は、システムが待つ複数バイトを一度
に比較演算する比較演算機能であって、例えば整数型デ
ータの4バイト(32ビット)を一度にビット対応で比較
演算(論理和、論理積、排他的論理和など)を行う機能
である。本実施例は、ソースプログラムの文字列中の空
白をこの整数型データとみなして複数バイト(例えば4
バイト)単位に比較して空白の読み飛ばしを少ないステ
ップ数で行うものである。尚、文字は、通常、その性質
上1バイト毎(1文字毎)に比較演算している。以下整
数型データの4バイトを一度に比較演算する比較演算機
能2を用いた場合の動作を、第1図ないしの順序
で、第2図を参照して具体的に説明する。The comparison operation function 2 is a comparison operation function for comparing a plurality of bytes that the system waits for at a time. For example, four bytes (32 bits) of integer-type data are bit-at-a-time corresponding to a comparison operation (logical sum, logical product, Exclusive OR). In the present embodiment, a blank in a character string of a source program is regarded as this integer type data and a plurality of bytes (for example, 4 bytes) are used.
In this method, blanks are skipped in a smaller number of steps than in units of (bytes). It should be noted that a character is normally subjected to a comparison operation for each byte (for each character) due to its nature. The operation in the case where the comparison operation function 2 for comparing four bytes of the integer type data at a time is used will be specifically described in the order shown in FIGS. 1 and 2 with reference to FIG.
第1図において、は、4バイトの文字列をソースプ
ログラム1から取り出し、これを整数型データとみなし
て4バイト分の空白文字列と排他的論理和をとる(比較
演算機能2)。これにより、ソースプログラム1から取
り出した4バイト分の文字列と、4バイト分の空白文字
列とをシステムが持つ比較演算機能2によって一度に排
他的論理和演算する。In FIG. 1, a 4-byte character string is extracted from the source program 1, and is regarded as integer-type data and exclusive-ORed with a 4-byte blank character string (comparison operation function 2). As a result, a 4-byte character string extracted from the source program 1 and a 4-byte blank character string are exclusively ORed at a time by the comparison operation function 2 of the system.
は、の結果が0(零)か否かを判別する。YESの
場合には、で4文字分が空白なので、字句解析の処理
位置を4バイト分進める。これは、例えば第2図(イ)
ソースプログラム1の現在の字句解析処理位置から取り
出した4バイト分の文字列“40404040"と、空白コード
“40404040"との排他的論理和演算を行ったの結果が
4バイト分、全て0(零)であったので、YESとな
り、で字句解析処理位置を4バイト分進め、4つの空
白を読み飛ばす。NOの場合には、を行う。Determines whether the result is 0 (zero). In the case of YES, since four characters are blank, the processing position of the lexical analysis is advanced by four bytes. This is, for example, FIG.
The exclusive OR operation of the 4-byte character string “40404040” extracted from the current lexical analysis processing position of the source program 1 and the blank code “40404040” results in a 4-byte result of all 0 (zero) ), The result is YES, and the lexical analysis processing position is advanced by 4 bytes to skip four blanks. If no, do.
は、の結果の先頭3バイトが0(零)か否かを判
別する。YESの場合には、で3文字分が空白なので、
字句解析の処理位置を3バイト分進める。これは、例え
ば第2図(ロ)ソースプログラム1の現在の字句解析処
理位置から取り出した4バイト分の文字列“404040E7"
と、空白コード“40404040"との排他的論理和演算を行
ったの結果が先頭から3バイト分、0(零)であった
ので、YESとなり、で字句解析処理位置を3バイト
分進め、3つの空白を読み飛ばす。NOの場合には、を
行う。Determines whether the first three bytes of the result are 0 (zero). In case of YES, 3 characters are blank
The processing position of the lexical analysis is advanced by 3 bytes. This is, for example, a 4-byte character string “404040E7” extracted from the current lexical analysis processing position of the source program 1 in FIG.
The result of performing an exclusive OR operation with the blank code "40404040" is 0 (zero) for 3 bytes from the beginning, so the result is YES, and the lexical analysis processing position is advanced by 3 bytes. Skip two blanks. If no, do.
は、の結果の先頭2バイトが0(零)か否かを判
別する。YESの場合には、で2文字分が空白なので、
字句解析の処理位置を2バイト分進める。これは、例え
ば第2図(ハ)ソースプログラム1の現在の字句解析処
理位置から取り出した4バイト分の文字列“4040F14B"
と、空白コード“40404040"との排他的論理和演算を行
ったの結果が先頭から2バイト分、0(零)であった
ので、YESとなり、で字句解析処置位置を2バイト
分進め、2つの空白を読み飛ばす。NOの場合には、を
行う。Determines whether the first two bytes of the result are 0 (zero). In case of YES, two characters are blank.
The processing position of the lexical analysis is advanced by 2 bytes. This is, for example, the character string “4040F14B” of 4 bytes extracted from the current lexical analysis processing position of the source program 1 in FIG.
The result of performing an exclusive OR operation with the blank code “40404040” is 0 (zero) for 2 bytes from the beginning, so the result is YES, and the lexical analysis processing position is advanced by 2 bytes. Skip two blanks. If no, do.
は、の結果の先頭1バイトが0(零)か否かを判
別する。YESの場合には、で1文字分が空白なので、
字句解析の処理位置を1バイト分進める。これは、例え
ば第2図(ニ)ソースプログラム1の現在の字句解析処
理位置から取り出した4バイト分の文字列“404E4040"
と、空白コード“40404040"との排他的論理和演算を行
ったの結果が先頭から1バイト分、0(零)であった
ので、YESとなり、で字句解析処理位置を1バイト
分進め、1つの空白を読み飛ばす。NOの場合には、を
行う。Determines whether the first byte of the result is 0 (zero). In case of YES, one character is blank.
The processing position of the lexical analysis is advanced by one byte. This corresponds to, for example, a 4-byte character string “404E4040” extracted from the current lexical analysis processing position of the source program 1 in FIG.
The result of performing an exclusive OR operation with the blank code "40404040" is 0 (zero) for 1 byte from the beginning, so the result is YES, and the lexical analysis processing position is advanced by 1 byte. Skip two blanks. If no, do.
は、の結果の先頭のバイトが0(零)でなく、空
白でないので、字句解析の取り出し処理を行う。これ
は、例えば第2図(ホ)ソースプログラム1の現在の字
句解析処理位置から取り出した4バイト分の文字列“C1
C2C340"と、空白コード“40404040"との排他的論理和演
算を行ったの結果の先頭バイトが0(零)でなかった
ので、NOとなり、字句の取出し処理を行う。Performs the lexical analysis extraction processing because the first byte of the result is not 0 (zero) and not a blank. This is, for example, the character string “C1” of 4 bytes extracted from the current lexical analysis processing position of the source program 1 in FIG.
Since the leading byte of the result of performing an exclusive OR operation between C2C340 "and the blank code" 40404040 "is not 0 (zero), the result is NO, and the lexical extraction processing is performed.
以上のように、ソースプログラム1から4バイト単位
に文字列を取り出し、これを4バイトの空白コードと排
他的論理和演算を行い、その結果の先頭から0(零)の
バイト数分だけ読み飛ばすことにより、少ないステップ
数で空白の読み飛ばしを行うことが可能となる。As described above, a character string is extracted from the source program 1 in 4-byte units, exclusive-ORed with a 4-byte blank code, and skipped by the number of 0 (zero) bytes from the beginning of the result. This makes it possible to skip blanks with a small number of steps.
第2図は、本発明の具体例説明図を示す。 FIG. 2 is a diagram illustrating a specific example of the present invention.
第2図(イ)は、第1図、YESのときの具体例を
示す。これは、ソースプログラム1から取り出した文字
列の4バイトが全て空白コードのときであり、4バイト
分読み飛ばす例である。FIG. 2 (a) shows a specific example when YES in FIG. This is a case where all four bytes of the character string extracted from the source program 1 are blank codes, and is an example of skipping four bytes.
第2図(ロ)は、第1図、YESのときの具体例を
示す。これは、ソースプログラム1から取り出した文字
列の4バイトのうちの先頭から3バイトが空白コードの
ときであり、3バイト分読み飛ばす例である。FIG. 2 (b) shows a specific example when YES in FIG. This is the case where the first three bytes of the four bytes of the character string extracted from the source program 1 are blank codes, and is an example of skipping three bytes.
第2図(ハ)は、第1図、YESのときの具体例を
示す。これは、ソースプログラム1から取り出した文字
列の4バイトのうちの先頭から2バイトが空白コードの
ときであり、2バイト分読み飛ばす例である。FIG. 2 (c) shows a specific example when YES in FIG. This is a case where the first two bytes of the four bytes of the character string extracted from the source program 1 are blank codes, and is an example of skipping two bytes.
第2図(ニ)は、第1図、YESのときの具体例を
示す。これは、ソースプログラム1から取り出した文字
列の4バイトのうちの先頭から1バイトが空白コードの
ときであり、1バイト分読み飛ばす例である。FIG. 2 (d) shows a specific example when YES in FIG. This is when one byte from the beginning of the four bytes of the character string extracted from the source program 1 is a blank code, and is an example of skipping one byte.
第2図(ホ)は、第1図、NOのときの具体例を示
す。これは、ソースプログラム1から取り出した文字列
の4バイトのうちの先頭バイトが空白コードでないとき
であり、この先頭から字句を取り出して字句解析を行う
例である。FIG. 2 (e) shows a specific example when NO in FIG. This is an example in which the first byte of the 4 bytes of the character string extracted from the source program 1 is not a blank code, and the lexical analysis is performed by extracting the lexical from the first byte.
以上説明したように、本発明によれば、システムが特
つ複数バイトを一度に比較演算する比較演算機能2を用
い、ソースプログラム1から複数バイト単位(例えば整
数型データの4バイト単位)に空白を判定して読み飛ば
す構成を採用しているため、空白の読み飛ばし処理のた
めの比較演算回数を削減して字句解析処理を高速に実行
することができる。As described above, according to the present invention, the system uses the comparison operation function 2 to compare and calculate a plurality of bytes at a time, and blanks the source program 1 in units of a plurality of bytes (for example, in units of 4 bytes of integer type data). Is adopted, and the number of comparison operations for the blank skipping process can be reduced, and the lexical analysis process can be executed at high speed.
第1図は本発明の1実施例構成図、第2図は本発明の具
体例説明図を示す。 図中、1はソースプログラム、2はシステムが持つ比較
演算機能を示す。FIG. 1 is a block diagram of one embodiment of the present invention, and FIG. 2 is a diagram illustrating a specific example of the present invention. In the figure, 1 indicates a source program, and 2 indicates a comparison operation function of the system.
Claims (1)
いて、 コンピュータシステムで動作する命令によって複数バイ
トを一度に比較演算する比較演算手段と、 ソースプログラムから取り出した上記複数バイト分の文
字列のコードと、上記複数バイト分の空白コードとの排
他的論理和演算を、命令を上記比較演算手段に発行して
行わせ、先頭からその結果が0(零)のバイト数だけ空
白と判定して読み飛ばし、0(零)でないバイトに該当
する字句を取り出して解析を行う手段とを備えたことを
特徴とする字句解析における空白読み飛ばし装置。An apparatus for skipping blanks in lexical analysis, comprising: a comparison operation means for comparing and calculating a plurality of bytes at a time by an instruction operating on a computer system; a code of a character string for the plurality of bytes extracted from a source program; The exclusive OR operation with the blank code for the plurality of bytes is performed by issuing an instruction to the comparison operation means, and the result is determined to be 0 (zero) bytes from the beginning and is skipped, Means for extracting a lexical character corresponding to a byte other than 0 (zero) and analyzing the extracted lexical character.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP32667389A JP2868127B2 (en) | 1989-12-15 | 1989-12-15 | Blank reading device in lexical analysis |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP32667389A JP2868127B2 (en) | 1989-12-15 | 1989-12-15 | Blank reading device in lexical analysis |
Publications (2)
Publication Number | Publication Date |
---|---|
JPH03186932A JPH03186932A (en) | 1991-08-14 |
JP2868127B2 true JP2868127B2 (en) | 1999-03-10 |
Family
ID=18190387
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP32667389A Expired - Fee Related JP2868127B2 (en) | 1989-12-15 | 1989-12-15 | Blank reading device in lexical analysis |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2868127B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH06175709A (en) * | 1992-12-04 | 1994-06-24 | Mitsubishi Electric Corp | Programming device |
-
1989
- 1989-12-15 JP JP32667389A patent/JP2868127B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JPH03186932A (en) | 1991-08-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114153496A (en) | Block chain-based high-speed parallelizable code similarity comparison method and system | |
JP2868127B2 (en) | Blank reading device in lexical analysis | |
JPH0520794B2 (en) | ||
JPH0619962A (en) | Text dividing device | |
JPH06290021A (en) | Method for compressing source program | |
JPS63170789A (en) | Pattern resemblance degree detection circuit | |
JP2835065B2 (en) | String search method | |
JP2728534B2 (en) | Byte position identification code setting processing method | |
JPH021027A (en) | Compiling system for compressed source program | |
CN116776326A (en) | System and method for detecting harmful script based on hash code set | |
CN110858227A (en) | Method and device for comparing sets | |
JP2590288B2 (en) | Program conversion device | |
JPS6336390A (en) | Check digit processing system | |
JPH02236777A (en) | Character retrieving system | |
JP3018579B2 (en) | Name search processor | |
JPH02219176A (en) | Character-string retrieving system | |
Sommerville | A pattern matching system | |
JPH07225763A (en) | Document processor | |
JPH07113894B2 (en) | Common character string search processor | |
JPH05324731A (en) | Retrieval processing system for data | |
JPH0265959A (en) | Automatic output system for work conditions | |
JPH0520041A (en) | Record layout generation processor | |
JPH0217534A (en) | Analyzing processing system for control sentence | |
JPH07210623A (en) | Document picture processor | |
JPH02285437A (en) | Detection processing system for file different point |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
LAPS | Cancellation because of no payment of annual fees |