<commit_before>/**
 * How to run:
 *
 *   ./bin/syntax \
 *     --grammar examples/s-expression.g \
 *     --mode slr1 \
 *     --parse '(+ 1 15)'
 *
 *   > ['+', 1, 15]
 *
 * See also recursive descent version for this grammar:
 * https://gist.github.com/DmitrySoshnikov/2a434dda67019a4a7c37
 */

{
  "lex": {
    "rules": [
      ["\\s+", "/* skip whitespace */"],
      ["\\d+", "return 'NUMBER';"],
      ["[a-zA-Z\\-\\+\\*\\?\\=/]+\\d*", "return 'SYMBOL';"],
      ["\\(", "return '('"],
      ["\\)", "return ')'"],
    ]
  },

  "bnf": {
    "s-exp": [["atom", "console.log('in atom', $1); return $$ = $1;"],
              ["list", "console.log('in list', $1); return $$ = $1;"]],

     "list": [["( list-entries )", "$$ = []; $$.push.apply($$, $2);"]],

     "list-entries": [["s-exp list-entries", "$$ = []; $$.push($1); $$.push.apply($$, $2);"],
                      ["ε", "$$ = [];"]],

     "atom": [["NUMBER", "console.log('XXX', yytext); $$ = Number(yytext);"],
              ["SYMBOL", "console.log('YYY', yytext); $$ = String(yytext);"]]
  }
}<commit_msg>Removed debug code from example<commit_after>/**
 * How to run:
 *
 *   ./bin/syntax \
 *     --grammar examples/s-expression.g \
 *     --mode slr1 \
 *     --parse '(+ 1 15)'
 *
 *   > ['+', 1, 15]
 *
 * See also recursive descent version for this grammar:
 * https://gist.github.com/DmitrySoshnikov/2a434dda67019a4a7c37
 */

{
  "lex": {
    "rules": [
      ["\\s+", "/* skip whitespace */"],
      ["\\d+", "return 'NUMBER';"],
      ["[a-zA-Z\\-\\+\\*\\?\\=/]+\\d*", "return 'SYMBOL';"],
      ["\\(", "return '('"],
      ["\\)", "return ')'"],
    ]
  },

  "bnf": {
    "s-exp": [["atom", "return $$ = $1;"],
              ["list", "return $$ = $1;"]],

     "list": [["( list-entries )", "$$ = []; $$.push.apply($$, $2);"]],

     "list-entries": [["s-exp list-entries", "$$ = []; $$.push($1); $$.push.apply($$, $2);"],
                      ["ε", "$$ = [];"]],

     "atom": [["NUMBER", "$$ = Number(yytext);"],
              ["SYMBOL", "$$ = yytext;"]]
  }
}
{'fraction_non_alphanumeric': 0.32419196865817823, 'fraction_numerical': 0.025465230166503428, 'mean_word_length': 2.1286370597243494, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '735474', 'n_tokens_mistral': 832, 'n_tokens_neox': 783, 'n_words': 134}