Sha256: bde6479bb6f95f46a57f1c4863474a58181173a87a18322e22c9907fc2d306e7

Contents?: true

Size: 1.86 KB

Versions: 7

Compression:

Stored size: 1.86 KB

Contents

%% 

lex 
    : definitions include '%%' rules '%%' EOF
        {{ $$ = {macros: $1, rules: $4};
          if ($2) $$.actionInclude = $2;
          return $$; }}
    | definitions include '%%' rules EOF
        {{ $$ = {macros: $1, rules: $4};
          if ($2) $$.actionInclude = $2;
          return $$; }}
    ;

include
    : action
    |
    ;

definitions
    : definitions definition
        { $$ = $1; $$.concat($2); }
    | definition
        { $$ = [$1]; }
    ;

definition
    : name regex
        { $$ = [$1, $2]; }
    ;

name
    : NAME
        { $$ = yytext; }
    ;

rules
    : rules rule
        { $$ = $1; $$.push($2); }
    | rule
        { $$ = [$1]; }
    ;

rule
    : regex action
        { $$ = [$1, $2]; }
    ;

action
    : ACTION 
        { $$ = yytext; }
    ;

regex
    : start_caret regex_list end_dollar
        { $$ = $1+$2+$3; }
    ;

start_caret
    : '^'
        { $$ = '^'; }
    |
        { $$ = ''; }
    ;

end_dollar
    : '$'
        { $$ = '$'; }
    |
        { $$ = ''; }
    ;

regex_list
    : regex_list '|' regex_list
        { $$ = $1+'|'+$3; }
    | regex_list regex_base
        { $$ = $1+$2;}
    | regex_base
        { $$ = $1;}
    ;

regex_base
    : '(' regex_list ')'
        { $$ = '('+$2+')'; }
    | regex_base '+'
        { $$ = $1+'+'; }
    | regex_base '*'
        { $$ = $1+'*'; }
    | regex_base '?'
        { $$ = $1+'?'; }
    | '/' regex_base
        { $$ = '(?='+$2+')'; }
    | name_expansion
    | regex_base range_regex
        { $$ = $1+$2; }
    | any_group_regex
    | '.'
        { $$ = '.'; }
    | string
    ;

name_expansion
    : '{' name '}'
        {{ $$ = '{'+$2+'}'; }}
    ;

any_group_regex
    : ANY_GROUP_REGEX
        { $$ = yytext; }
    ;

range_regex
    : RANGE_REGEX
        { $$ = yytext; }
    ;

string
    : STRING_LIT
        { $$ = yy.prepareString(yytext.substr(1, yytext.length-2)); }
    ;

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
haml-more-0.5.1 vendor/coffee-script/vendor/jison/tests/grammar/lex.jison
haml-more-0.5.0 vendor/coffee-script/vendor/jison/tests/grammar/lex.jison
haml-more-0.4.0 vendor/coffee-script/vendor/jison/tests/grammar/lex.jison
haml-more-0.4.0.d vendor/coffee-script/vendor/jison/tests/grammar/lex.jison
haml-more-0.4.0.c vendor/coffee-script/vendor/jison/tests/grammar/lex.jison
haml-more-0.4.0.b vendor/coffee-script/vendor/jison/tests/grammar/lex.jison
haml-more-0.4.0.a vendor/coffee-script/vendor/jison/tests/grammar/lex.jison