You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aleksey Chichenkov 1091e507b6 readme 1 year ago
documentation first commit 1 year ago
example remove dependencies 1 year ago
lemon-src rm 1 year ago
libs remove dependencies 1 year ago
parser_template fix readme and add input config 1 year ago
require_js template 1 year ago
README.md readme 1 year ago
build-example.sh readme 1 year ago
build.sh remove dependencies 1 year ago
config.example fix readme and add input config 1 year ago
config.template fix readme and add input config 1 year ago
main.js add require_template 1 year ago
package.json remove dependencies 1 year ago
test.js remove dependencies 1 year ago

README.md

Requires

  • node
  • npm
  • gcc

Install

# bash
git clone -- http://git.macaw.me:3000/chichenkov/LemonJS
cd LemonJS

gcc -o ./lemon-src/lemon-js -O2 ./lemon-src/lemon-js.c
#or
./build.sh

Start

node main.js --c=<your_config>.js --t=<web|node>

Example (One minute start)

Also you can build example config

./build-example.sh

node main.js
#or test if want check work
node test.js

Configurate

You need create your config.js from config.template or config.example

var config = {
    lemon_bin: "./lemon-src/lemon-js", // папка с исходниками лемона
    input_path: "parser_template/", // папка с шаблоном парсера
    output_path: "out/", // папка куда будет выгружен файл
    file_name: "parser", // имя файла шаблона
    flags: "-l", // флаги для ./lemon-js
    require_template: "require_js/" // Папка для шаблона require_js/
};
cat config.template > config.js
# or
cat config.example > config.js

Test

Also you can test your parser

node test.js --c=<your_config>.js

Also

You can use this syntax for include your *.y file.

<&&REPLACER{<file_path>}&&>

Special Directives

See lemon.html for additional documentation.

  • %name - Set parser class name (default is “Parse”)
  • %include - Include code in the beginning of file (usefull for imports)
  • %code - Include code in the end of file (usefull for exports or main code)
  • %token_destructor - Define code which will be executed on token destruction.
  • %default_destructor
  • %token_prefix - Define token name prefix.
  • %syntax_error - Define custom error handler for syntax erorrs.
  • %parse_accept - Define handler for all accepted tokens.
  • %parse_failure - Define handler for parse errors.
  • %stack_overflow - Define handler for stack overflow.
  • %extra_argument - NOT SUPPORTED
  • %token_type - NOT SUPPORTED
  • %default_type - NOT SUPPORTED
  • %stack_size - Set default stack size.
  • %start_symbol
  • %left - Set left associative tokens.
  • %right - Set right associative tokens.
  • %nonassoc - Set non associative tokens.
  • %destructor - Define custom parser destructor.
  • %type - NOT SUPPORTED
  • %fallback - Define fallback logic for tokens.
  • %wildcard - Define WILDCARD token.
  • %token_class - NOT SUPPORTED

Lexer

Used re2js lexer from: http://git.macaw.me:3000/chichenkov/re2-js-generator

Original project

See https://github.com/sormy/lemon-js