用Javascript编写的Lexer? [英] Lexer written in Javascript?

查看:548
本文介绍了用Javascript编写的Lexer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,用户需要为一个完全用javascript编写的ui定义一组指令。我需要能够解析一串指令然后将它们转换成指令。是否有任何库可用于解析100%javascript?或者将在javascript中生成的生成器?谢谢!

I have a project where a user needs to define a set of instructions for a ui that is completely written in javascript. I need to have the ability to parse a string of instructions and then translate them into instructions. Is there any libraries out there for parsing that are 100% javascript? Or a generator that will generate in javascript? Thanks!

推荐答案

http://jscc.phorward-software.com/ ,也许?


JS / CC是在Wikipedia上获取有关ECMAScript的更多信-derivates。它已经开发出来,旨在构建一个高效的编译器开发系统,并打算为那些对解析表生成方式感兴趣的人创建一个易于使用的学术环境。
自下而上解析。

JS/CC is the first available parser development system for JavaScript and ECMAScript-derivates. It has been developed, both, with the intention of building a productive compiler development system and with the intention of creating an easy-to-use academic environment for people interested in how parse table generation is done general in bottom-up parsing.

独立于平台的软件工会:基于正则表达式词法分析器生成器匹配输入字符流中的各个令牌和 a LALR(1)解析器生成器上获取有关LALR(1)的更多信息,计算给定的更多关于Context-Free Grammars维基百科的信息 - 免费语法规范和bu建立一个独立的,有效的解析器。提供给JS / CC的无上下文语法在 Backus-Naur-Form 为基础的元语言形式,允许插入单个语义代码,以便根据规则的减少进行评估。

The platform-independent software unions both: A regular expression-based lexical analyzer generator matching individual tokens from the input character stream and a LALR(1) parser generator, computing the parse tables for a given context-free grammar specification and building a stand-alone, working parser. The context-free grammar fed to JS/CC is defined in a Backus-Naur-Form-based meta language, and allows the insertion of individual semantic code to be evaluated on a rule's reduction.

JS / CC本身完全用ECMAScript编写,因此可以通过多种不同的方式执行:作为平台无关,嵌入在网站上的基于浏览器的JavaScript,作为Windows脚本宿主应用程序,作为编译JScript.NET可执行文件,作为Mozilla / Rhino或Mozilla / Spidermonkey解释的应用程序,或Windows,* nix,Linux和Mac OSX上的V8 shell脚本。但是,为了高效执行,建议使用命令行版本。这些版本能够从JS / CC解析器规范组装完整的编译器,然后将其存储到.js JavaScript源文件中。

JS/CC itself has been entirely written in ECMAScript so it can be executed in many different ways: as platform-independent, browser-based JavaScript embedded on a Website, as a Windows Script Host Application, as a compiled JScript.NET executable, as a Mozilla/Rhino or Mozilla/Spidermonkey interpreted application, or a V8 shell script on Windows, *nix, Linux and Mac OSX. However, for productive execution, it is recommended to use the command-line versions. These versions are capable of assembling a complete compiler from a JS/CC parser specification, which is then stored to a .js JavaScript source file.

这篇关于用Javascript编写的Lexer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆