Function() way of generating code breaks for slightly more complication %{...%} action snippets #150

Merged
merged 1 commit into from Apr 17, 2013

2 participants

@GerHobbelt

(manual extract from #143)

  • (SHA-1: 47206a3) * patched the code generator as it broke on the offending line (where the action code is poured into a Function()) for action blocks such as this one:

    ... rule ...
    | TAN '(' e ')'
    {
    $$ = {
    token: FKW_FUNCTION,
    token_attr: FKA_ABSOLUTE,
    childs: [null, $3],
    loc_info: @$,
    type: FT_NUMBER,
    unit: $3.unit,
    value: Math.abs($3.value)
    };
    }

The object creation like that would produce a 'Unexpected symbol' error.

@GerHobbelt GerHobbelt (SHA-1: 47206a3) * patched the code generator as it broke on the offe…
…nding line (where the action code is poured into a Function()) for action blocks such as this one:

    ... rule ...
    | TAN '(' e ')'
        {
            $$ = {
                token:      FKW_FUNCTION,
                token_attr: FKA_ABSOLUTE,
                childs:     [null, $3],
                loc_info:   @$,
                type:       FT_NUMBER,
                unit:       $3.unit,
                value:      Math.abs($3.value)
            };
        }

The object creation like that would produce a 'Unexpected symbol' error.
a11564d
@zaach
Owner

It seems like a perfectly reasonable action block... I'll add a test case. Also, performAction is generated with Function so that the parser can be used dynamically – skipping the generation step. It's another question of whether we should keep that use-case or not.

BTW, thanks for all of these patches. Good thing it is a long weekend!

@GerHobbelt
@zaach zaach merged commit 81678e7 into zaach:master Apr 17, 2013

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment