Skip to content

Commit

Permalink
Fix bug in Lua parsing of table initializers.
Browse files Browse the repository at this point in the history
This was reported to PEGTL upstream: taocpp/PEGTL#67
  • Loading branch information
samhocevar committed Aug 4, 2017
1 parent 4cc1c9b commit 2dec0d9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lua53-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ namespace lua53
template< typename E >
struct statement_list : pegtl::seq< seps, pegtl::until< pegtl::sor< E, pegtl::if_must< key_return, statement_return, E > >, statement, seps > > {};

template< char O, char... N >
struct op_one : pegtl::seq< pegtl::one< O >, pegtl::at< pegtl::not_one< N... > > > {};
template< char O, char P, char... N >
struct op_two : pegtl::seq< pegtl::string< O, P >, pegtl::at< pegtl::not_one< N... > > > {};

struct table_field_one : pegtl::if_must< pegtl::one< '[' >, seps, expression, seps, pegtl::one< ']' >, seps, pegtl::one< '=' >, seps, expression > {};
struct table_field_two : pegtl::if_must< pegtl::seq< name, seps, pegtl::one< '=' > >, seps, expression > {};
struct table_field_two : pegtl::if_must< pegtl::seq< name, seps, op_one< '=', '=' > >, seps, expression > {};
#if WITH_PICO8
struct table_field : pegtl::sor< table_field_one, disable_backtracking< table_field_two >, expression > {};
#else
Expand Down Expand Up @@ -268,11 +273,6 @@ namespace lua53
struct variable : pegtl::seq< variable_head, pegtl::star< pegtl::star< seps, function_call_tail >, seps, variable_tail > > {};
struct function_call : pegtl::seq< function_call_head, pegtl::plus< pegtl::until< pegtl::seq< seps, function_call_tail >, seps, variable_tail > > > {};

template< char O, char... N >
struct op_one : pegtl::seq< pegtl::one< O >, pegtl::at< pegtl::not_one< N... > > > {};
template< char O, char P, char... N >
struct op_two : pegtl::seq< pegtl::string< O, P >, pegtl::at< pegtl::not_one< N... > > > {};

template< typename S, typename O >
struct left_assoc : pegtl::seq< S, seps, pegtl::star< pegtl::if_must< O, seps, S, seps > > > {};
template< typename S, typename O >
Expand Down

0 comments on commit 2dec0d9

Please sign in to comment.