• 検索結果がありません。

ANTLR を用いた信頼性の高い JavaScript 構文解析器の開発 要旨

N/A
N/A
Protected

Academic year: 2021

シェア "ANTLR を用いた信頼性の高い JavaScript 構文解析器の開発 要旨"

Copied!
4
0
0

読み込み中.... (全文を見る)

全文

(1)

要 旨

ANTLR を用いた信頼性の高い JavaScript 構文解析器の開発

中尾 成一

JavaScript のプログラムを実行するためのソフトウェアが JavaScript 処理系である.

JavaScript処理系の開発ではJavaScriptの構文解析器を作る必要がある.JavaScriptの構 文解析器は,JavaScriptのプログラムを入力として受け取り,それが言語の文法に従った ものであるかどうかを調べて木構造の構文木を生成する.JavaScriptのプログラムを構文 解析する既存の構文解析ライブラリがあれば,それを利用することで開発コストを軽減す ることができる.Java言語を使ってJavaScript処理系を開発する場合は,Java言語で記

述されたJavaScriptの構文解析ライブラリが必要になる.しかし,Java言語で記述された

JavaScriptの構文解析ライブラリで信頼性が高いものは存在しない.

本研究では,Java言語で記述された信頼性の高いJavaScript構文解析ライブラリを開発 した.本研究では信頼性を,様々なJavaScriptのプログラムを入力として,仕様通りに構文 木を構築できる割合として定義する.対象とするJavaScriptのバージョンはECMAScript

5th Edition(以下,ES5)である.本研究で開発した構文解析器は,ESTreeというスキー

マに従った構文木を生成する.ESTree は既存の JavaScriptの構文解析ライブラリである

Esprimaが生成する構文木のスキーマである.本研究の構文解析器の一部は,構文解析器生

成系のANTLRを用いて,オープンソースで公開されているJavaScriptの文法記述から自

動生成した.それに加えて,自動生成された構文解析器が出力する解析木をESTreeに変換 するプログラムを開発した.さらに,Esprimaのテストケースを使って開発した構文解析器 の信頼性を検査した.Esprimaは,JavaScriptで書かれた信頼性の高いJavaScriptの構文 解析器である.Esprimaは,1300個ほどのJavaScriptプログラムからなる網羅率の高いテ ストケースを持っている.このテストケースは本研究で開発した構文解析器の信頼性を確か

i

(2)

めることに適している.構文解析器の信頼性検査では,各テストケースを構文解析し,構文 木が正解と一致するかどうかを調べた.なお,EsprimaES5と上位互換性のある上位の バージョンに対応しているため,ES5の範囲のテストケースのみを用いた.検査の結果,文 法記述にいくつかの誤りが見つかった.これらの誤りを修正して,ES5の主要な構文のテス トケースをすべて正しく構文解析する構文解析器を開発した.

キーワード 構文解析器,JavaScript,プログラムテスト

ii

(3)

Abstract

Development of a Highly Reliable JavaScript Parser by Using ANTLR

Seichi NAKAO

A JavaScript processing system is software that executes JavaScript programs. It is necessary to develop a JavaScript parser in development of JavaScript processing sys- tems. JavaScript parsers receive JavaScript programs as their input, examine whether the programs connect with respect to the JavaScript grammar, and generate abstract syntax trees. If we have a parser library that parses JavaScript programs, we can reduce the development cost of JavaScript processing systems by using the library. To develop a JavaScript processing system written in Java, the parser should also be written in Java. Unfortunately, we could not find any reliable JavaScript parser library written in Java.

In this study, we developed a highly reliable JavaScript parser library written in Java. We define the reliability as the ratio that JavaScript programs are parsed into cor- rect abstract syntax trees. The parser generates abstract syntax trees ESTree. ESTree is the schema of abstract syntax trees generated by Esprima that is an existing JavaScript parser library. We generated a part of the parser from an open source JavaScript gram- mar definition. In addition, we developed a program to convert parse trees into ESTree.

Furthermore, in this study, we tested the reliability of the parser by using test cases of Esprima. Esprima is a highly reliable JavaScript parser written in JavaScript. Esprima has test cases with high code coverage consisting of about 1300 JavaScript programs.

iii

(4)

These test cases have been suitable for testing the reliability of the parser developed in this study. The reliability of the parser was tested by comparing the abstract syntax trees outputted by the parser with the correct abstract syntax trees. Esprima is a higher version that is compatible with ES5, so only we used the test cases that were programs of the range of ES5. As a result of the test, we found some grammatical errors in the JavaScript grammar definition. By correcting these grammatical errors, we developed the parser that correctly parses all the test cases with main grammatical constructions of ES5.

key words parserJavaScriptprogram test

iv

参照

関連したドキュメント

節の構造を取ると主張している。 ( 14b )は T-ing 構文、 ( 14e )は TP 構文である が、 T-en 構文の例はあがっていない。 ( 14a

そこで本解説では,X線CT画像から患者別に骨の有限 要素モデルを作成することが可能な,画像処理と力学解析 の統合ソフトウェアである

3He の超流動は非 s 波 (P 波ー 3 重項)である。この非等方ペアリングを理解する

解析の教科書にある Lagrange の未定乗数法の証明では,

しかし , 特性関数 を使った証明には複素解析や Fourier 解析の知識が多少必要となってくるため , ここではより初等的な道 具のみで証明を実行できる Stein の方法

※ CMB 解析や PMF 解析で分類されなかった濃度はその他とした。 CMB

2 次元 FEM 解析モデルを添図 2-1 に示す。なお,2 次元 FEM 解析モデルには,地震 観測時点の建屋の質量状態を反映させる。.

解析においては、実際に計測された格納容器圧力の値にある程度あわせる ため、原子炉圧力容器破損時に原子炉建屋補機冷却系配管の損傷による漏え