gpt4 book ai didi

javascript - 词法分析器是用 Javascript 编写的吗?

转载 作者:行者123 更新时间:2023-12-02 23:53:19 25 4
gpt4 key购买 nike

我有一个项目,用户需要为完全用 JavaScript 编写的 ui 定义一组指令。我需要有能力解析一串指令,然后将它们翻译成指令。有没有 100% javascript 的解析库?或者用 javascript 生成的生成器?谢谢!

最佳答案

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

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 inbottom-up parsing.

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 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 - 词法分析器是用 Javascript 编写的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1823612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com