1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 /* File: shapesparser.y
21 * Yacc input file to generate the parser for the Shapes language
26 /* Just like lex, the text within this first region delimited by %{ and %}
27 * is assumed to be C/C++ code and will be copied verbatim to the y.tab.c
28 * file ahead of the definitions of the yyparse() function. Add other header
29 * file inclusions or C++ variable declarations/prototypes that are needed
32 #include "shapestypes.h"
37 #include "astvalues.h"
40 #include "shapesexceptions.h"
42 #include "charptrless.h"
43 #include "autoonoff.h"
44 #include "shapescore.h"
45 #include "texlabelmanager.h"
47 using namespace Shapes;
49 extern YYLTYPE shapeslloc;
53 * Warning! Warning! Warning!
54 * We'll soon use that yylex was defined as
55 * #define yylex shapeslex
56 * in order to reset it after we're done with the inclusion.
60 #include "shapesscanner.h"
63 return Ast::theShapesScanner.yylex( );
65 #define yylex shapeslex
80 void shapeserror( RefCountPtr< const char > msg )
82 throw Exceptions::ParserError( shapeslloc, msg );
85 void shapeserror( const char * msg )
87 shapeserror( strrefdup( msg ) );
94 * The section before the first %% is the Definitions section of the yacc
95 * input file. Here is where you declare tokens and types, add precedence
96 * and associativity options, and so on.
102 * Here we define the type of the yylval global variable that is used by
103 * the scanner to store attibute information about the token just scanned
104 * and thus communicate that information to the parser. You will need to
105 * add new fields to this union as you add different attributes to your
106 * non-terminal symbols.
110 Ast::Expression * expr;
112 Ast::MethodIdExpr * methodId;
113 std::list< Ast::Node * > * nodeList;
114 std::list< Ast::Expression * > * exprList;
115 std::list< RefCountPtr< const char > > * strList;
116 std::map< const char *, Ast::Expression *, charPtrLess > * namedExprMap;
117 Kernel::Formals * formals;
118 std::list< Kernel::Formals * > * formalsList;
119 Ast::ArgListExprs * argList;
120 Ast::SplitDefineVariables * splitFormals;
126 Lang::String * Lang_String;
127 std::list< const Ast::CallExpr * > * callExprList;
128 std::list< Ast::ClassSection * > * classSectionList;
129 Ast::ClassSection * classSection;
130 Ast::MemberSection * memberSection;
131 Ast::MemberDeclaration * memberDeclaration;
132 Ast::StateReference * stateReference;
133 Ast::MemberMode memberMode;
134 Ast::ClassMode classMode;
135 Ast::FunctionMode functionMode;
142 * Here we tell yacc about all the token types that we are using.
143 * Yacc will assign unique numbers to these and export the #define
144 * in the generated y.tab.h header file.
147 %token <tokenID> T_EOF T_preludesep T_minusminus T_plusplus T_ddot T_dddot T_assign T_eqeq T_eqneq T_atat T_projection T_angle T_ampersandMore
148 %token <tokenID> T_cycle T_and T_or T_xor T_not T_mapsto T_emptybrackets T_dddotbrackets T_compose T_surrounding T_lesseq T_greatereq T_llthan T_ggthan T_declaretype
149 %token <tokenID> T_tex T_indexof T_depthof T_variableName T_dynamic T_continuation T_continue T_esc_continuation T_esc_continue T_esc_backtrace
150 %token <tokenID> T_class T_members T_prepare T_abstract T_overrides T_gr__
151 %token <tokenID> T_split T_splitLeft T_splitRight T_unionLeft T_unionRight T_absLeft T_absRight
152 %token <tokenID> T_srcLoc
153 %token <tokenID> T_interactiveMark
155 %token <intVal> T_int
156 %token <floatVal> T_float T_length
157 %token <expr> T_speciallength
158 %token <boolVal> T_bool
159 %token <char_p> T_identifier T_dynamic_identifier T_state_identifier T_dynamic_state_identifier T_typename
160 %token <Lang_String> T_string
162 /* Non-terminal types
164 * In order for yacc to assign/access the correct field of $$, $1, we
165 * must to declare which field is appropriate for the non-terminal.
166 * As an example, this first type declaration establishes that the DeclList
167 * non-terminal uses the field named "declList" in the yylval union. This
168 * means that when we are setting $$ for a reduction for DeclList ore reading
169 * $n which corresponds to a DeclList nonterminal we are accessing the field
170 * of the union named "declList" which is of type List<Decl*>.
171 * pp2: You'll need to add many of these of your own.
174 %type <expr> Program Expr ExprExceptConstStrings DynamicBinding CallExpr CurryCallExpr MutateExpr Function OperatorFunction Class ConstantExceptStrings Coords PolarHandle
175 %type <expr> CodeBracket SuperCall SuperMemberReference
176 %type <exprList> InsertionSequence
177 %type <node> GroupElem
178 %type <nodeList> Group OneOrMoreGroupElems
179 %type <strList> OrderedFormals OneOrMoreOrderedFormals
180 %type <formals> Formals OneOrMoreFormalsItems
181 // %type <formalsList> NamedFormalsWithOrder OneOrMoreNamedFormalsWithOrder
182 %type <argList> ArgList OneOrMoreArgListItems
183 %type <methodId> MethodIdentifier
184 %type <callExprList> ListOfParentsWithInitargs;
185 %type <classSectionList> ClassSections OneOrMoreClassSections
186 %type <classSection> ClassSection
187 %type <memberSection> MemberDeclarations OneOrMoreMemberDeclarations
188 %type <memberSection> MethodDeclarations OneOrMoreMethodDeclarations
189 %type <memberDeclaration> MemberDeclaration MethodDeclaration
190 %type <memberMode> MemberAccessList MemberAccessSpecifier
191 %type <classMode> ClassModeList ClassModeSpecifier OneOrMoreClassModeSpecifiers
192 %type <functionMode> FunctionModeList OneOrMoreFunctionModeSpecifiers FunctionModeSpecifier
194 %type <stateReference> StateReference
195 %type <splitFormals> SplitFormals OneOrMoreSplitFormals
197 %nonassoc T_assign ':'
204 %left T_emptybrackets T_dddotbrackets T_ggthan
206 %left T_ampersandMore
208 %nonassoc T_dynamiccolon
214 %nonassoc T_eqeq T_eqneq T_lesseq T_greatereq
216 %left T_plusplus T_minusminus
221 %left '*' '/' T_projection
229 %left T_atat T_surrounding
235 %name-prefix="shapes"
239 * All productions and actions should be placed between the start and stop
240 * %% markers which delimit the Rules section.
244 : Group T_preludesep Group T_EOF
246 /* Note that the source location of the prelude is discarded. */
247 $1->push_back( new Ast::CodeBracket( @3, $3 ) );
248 $$ = new Ast::CodeBracket( @3, $1 );
249 Ast::theProgram = $$;
252 | T_interactiveMark Group T_EOF
254 Ast::theInteractiveInput = $2;
259 shapeserror( "Expecting end of file." );
265 : '(' Expr ',' Expr ')'
267 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
268 args->orderedExprs_->push_back( $2 );
269 args->orderedExprs_->push_back( $4 );
270 $$ = new Ast::CallExpr( @$,
271 Ast::THE_FUNCTION_coords2D,
274 | '(' Expr ',' Expr '^' Expr ')'
276 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
277 args->orderedExprs_->push_back( $2 );
278 args->orderedExprs_->push_back( $4 );
279 args->orderedExprs_->push_back( $6 );
280 $$ = new Ast::CallExpr( @$,
281 Ast::THE_FUNCTION_cornercoords2D,
284 | '(' Expr ',' Expr '^' ')'
286 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
287 args->orderedExprs_->push_back( $2 );
288 args->orderedExprs_->push_back( $4 );
289 $$ = new Ast::CallExpr( @$,
290 Ast::THE_FUNCTION_cornercoords2D,
293 | '(' Expr ',' Expr ',' Expr ')'
295 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
296 args->orderedExprs_->push_back( $2 );
297 args->orderedExprs_->push_back( $4 );
298 args->orderedExprs_->push_back( $6 );
299 $$ = new Ast::CallExpr( @$,
300 Ast::THE_FUNCTION_coords3D,
307 : '(' Expr '^' Expr ')'
309 $$ = new Ast::PolarHandle2DExpr( @$, $2, $4 );
313 $$ = new Ast::PolarHandle2DExprFree_a( @$, $2 );
317 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
318 args->orderedExprs_->push_back( $3 );
319 $$ = new Ast::CallExpr( @$,
320 Ast::THE_FUNCTION_polarHandle2DFree_r,
325 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
326 $$ = new Ast::CallExpr( @$,
327 Ast::THE_FUNCTION_polarHandle2DFree_ra,
335 $$ = new Ast::LexiographicState( @1, $1, new Kernel::Environment::LexicalKey * ( 0 ) );
337 | T_dynamic_state_identifier
339 $$ = new Ast::DynamicState( @1, $1 );
346 $$ = new Ast::ArgListExprs( true );
348 | OneOrMoreArgListItems
351 OneOrMoreArgListItems
354 $$ = new Ast::ArgListExprs( true );
355 $$->orderedExprs_->push_back( $1 );
359 $$ = new Ast::ArgListExprs( true );
360 $$->orderedStates_->push_back( $1 );
362 | T_identifier ':' Expr
364 $$ = new Ast::ArgListExprs( true );
365 (*$$->namedExprs_)[ $1 ] = $3;
367 | T_state_identifier ':' StateReference
369 $$ = new Ast::ArgListExprs( true );
370 (*$$->namedStates_)[ $1 ] = $3;
372 | OneOrMoreArgListItems Expr
375 if( ! $$->namedExprs_->empty( ) )
377 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Unnamed expressions may not appear among named expressions." ) ) );
379 $$->orderedExprs_->push_back( $2 );
381 | OneOrMoreArgListItems StateReference
384 if( ! $$->namedStates_->empty( ) )
386 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Unnamed states may not appear among named states." ) ) );
388 $$->orderedStates_->push_back( $2 );
390 | OneOrMoreArgListItems T_identifier ':' Expr
393 if( $$->namedExprs_->find( $2 ) != $$->namedExprs_->end( ) )
395 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
397 (*$$->namedExprs_)[ $2 ] = $4;
399 | OneOrMoreArgListItems T_state_identifier ':' StateReference
402 if( $$->namedStates_->find( $2 ) != $$->namedStates_->end( ) )
404 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
406 (*$$->namedStates_)[ $2 ] = $4;
412 : '[' Expr ArgList ']'
414 $$ = new Ast::CallExpr( @$, $2, $3 );
416 | Expr T_emptybrackets Expr
418 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
419 args->orderedExprs_->push_back( $3 );
420 $$ = new Ast::CallExpr( @$,
426 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
427 args->orderedExprs_->push_back( $1 );
428 $$ = new Ast::CallExpr( @$,
432 | Expr T_emptybrackets Split
434 $$ = new Ast::CallSplitExpr( @$,
438 | Expr T_dddotbrackets Expr
440 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
441 args->orderedExprs_->push_back( $3 );
442 $$ = new Ast::CallExpr( @$,
445 true ); /* true means Curry */
447 | Expr T_dddotbrackets T_identifier ':' Expr %prec T_dynamiccolon
449 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
450 (*args->namedExprs_)[ $3 ] = $5;
451 $$ = new Ast::CallExpr( @$,
454 true ); /* true means Curry */
456 | Expr T_dddotbrackets Split
458 $$ = new Ast::CallSplitExpr( @$,
461 true ); /* true means Curry */
467 : '[' Expr ArgList T_dddot ']'
469 $$ = new Ast::CallExpr( @$, $2, $3, true ); /* true means Curry */
474 : StateReference '.' '[' T_identifier ArgList ']'
476 Ast::CallExpr * res =
477 new Ast::CallExpr( @$,
478 new Ast::MutatorReference( @4, $1, $4 ),
480 res->setMutatorSelf( $1 );
488 $$ = new Kernel::Formals( );
491 | T_split T_identifier
493 $$ = new Kernel::Formals( );
494 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $2, $$->defaultExprs_.size( ) ) );
495 /* Note that we do not push a default expression (not even a null pointer) for the sink.
496 * This way, the length of defaultExprs_ allways gives the number of non-sink arguments.
497 * The default value for the sink is taken care of in a non-standard way anyway.
502 | OneOrMoreFormalsItems
507 | OneOrMoreFormalsItems T_split T_identifier
510 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $3, $$->defaultExprs_.size( ) ) );
511 /* Note that we do not push a default expression (not even a null pointer) for the sink.
512 * This way, the length of defaultExprs_ allways gives the number of non-sink arguments.
513 * The default value for the sink is taken care of in a non-standard way anyway.
520 OneOrMoreFormalsItems
523 $$ = new Kernel::Formals( );
524 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $1, $$->defaultExprs_.size( ) ) );
525 $$->defaultExprs_.push_back( 0 );
527 | T_identifier ':' Expr
529 $$ = new Kernel::Formals( );
530 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $1, $$->defaultExprs_.size( ) ) );
531 $$->defaultExprs_.push_back( $3 );
535 $$ = new Kernel::Formals( );
536 $$->stateOrder_->insert( std::pair< const char *, size_t >( $1, $$->stateOrder_->size( ) ) );
538 | OneOrMoreFormalsItems T_identifier
541 if( $$->seenDefault_ )
543 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Order-based formals may not appear among named formals." ) ) );
545 if( $$->argumentOrder_->find( $2 ) != $$->argumentOrder_->end( ) )
547 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
549 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $2, $$->defaultExprs_.size( ) ) );
550 $$->defaultExprs_.push_back( 0 );
552 | OneOrMoreFormalsItems T_identifier ':' Expr
555 $$->seenDefault_ = true;
556 if( $$->argumentOrder_->find( $2 ) != $$->argumentOrder_->end( ) )
558 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
560 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $2, $$->defaultExprs_.size( ) ) );
561 $$->defaultExprs_.push_back( $4 );
563 | OneOrMoreFormalsItems T_state_identifier
566 if( $$->stateOrder_->find( $2 ) != $$->stateOrder_->end( ) )
568 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
570 $$->stateOrder_->insert( std::pair< const char *, size_t >( $2, $$->stateOrder_->size( ) ) );
578 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @$, strrefdup( "The list of split assignment variables must not be empty." ) ) );
579 $$ = new Ast::SplitDefineVariables( );
581 | T_split T_identifier
583 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @$, strrefdup( "Just a sink in a split assignment formals list makes no sense." ) ) );
584 $$ = new Ast::SplitDefineVariables( );
586 | OneOrMoreSplitFormals
590 | OneOrMoreSplitFormals T_split T_identifier
593 Ast::StructSplitSink * expr = new Ast::StructSplitSink( );
594 size_t ** pos = new size_t * ( 0 );
595 $$->sinkDefine_ = new Ast::DefineVariable( @3, $3, expr, pos );
596 $$->sinkExpr_ = expr;
600 OneOrMoreSplitFormals
603 $$ = new Ast::SplitDefineVariables( );
604 typedef typeof $$->exprs_ ListType;
605 size_t ** pos = new size_t * ( 0 );
606 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @1, static_cast< size_t >( 0 ), 0 );
607 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
610 | T_identifier ':' Expr
612 $$ = new Ast::SplitDefineVariables( );
613 typedef typeof $$->exprs_ ListType;
614 size_t ** pos = new size_t * ( 0 );
615 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @1, static_cast< size_t >( 0 ), $3 );
616 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
619 | T_identifier ':' '.' T_identifier
621 $$ = new Ast::SplitDefineVariables( );
622 typedef typeof $$->exprs_ ListType;
623 size_t ** pos = new size_t * ( 0 );
624 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, $4, 0 );
625 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
628 | T_identifier ':' '.' T_identifier ':' Expr
630 $$ = new Ast::SplitDefineVariables( );
631 typedef typeof $$->exprs_ ListType;
632 size_t ** pos = new size_t * ( 0 );
633 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, $4, $6 );
634 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
637 | T_identifier ':' '.' '\"'
639 $$ = new Ast::SplitDefineVariables( );
640 typedef typeof $$->exprs_ ListType;
641 size_t ** pos = new size_t * ( 0 );
642 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, strdup( $1 ), 0 );
643 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
646 | T_identifier ':' '.' '\"' ':' Expr
648 $$ = new Ast::SplitDefineVariables( );
649 typedef typeof $$->exprs_ ListType;
650 size_t ** pos = new size_t * ( 0 );
651 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, strdup( $1 ), $6 );
652 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
655 | OneOrMoreSplitFormals T_identifier
660 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Order-based formals may not appear among named formals." ) ) );
662 if( $$->seenDefault_ )
664 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "All order-based formals without default values must be placed before those with default values." ) ) );
666 typedef typeof $$->exprs_ ListType;
667 size_t ** pos = new size_t * ( 0 );
668 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @2, $$->exprs_.size( ), 0 );
669 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
672 | OneOrMoreSplitFormals T_identifier ':' Expr
677 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Order-based formals may not appear among named formals." ) ) );
679 $$->seenDefault_ = true;
680 typedef typeof $$->exprs_ ListType;
681 size_t ** pos = new size_t * ( 0 );
682 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @2, $$->exprs_.size( ), $4 );
683 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
686 | OneOrMoreSplitFormals T_identifier ':' '.' T_identifier
689 $$->seenNamed_ = true;
690 typedef typeof $$->exprs_ ListType;
691 size_t ** pos = new size_t * ( 0 );
692 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, $5, 0 );
693 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
696 | OneOrMoreSplitFormals T_identifier ':' '.' T_identifier ':' Expr
699 $$->seenNamed_ = true;
700 typedef typeof $$->exprs_ ListType;
701 size_t ** pos = new size_t * ( 0 );
702 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, $5, $7 );
703 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
706 | OneOrMoreSplitFormals T_identifier ':' '.' '\"'
709 $$->seenNamed_ = true;
710 typedef typeof $$->exprs_ ListType;
711 size_t ** pos = new size_t * ( 0 );
712 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, strdup( $2 ), 0 );
713 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
716 | OneOrMoreSplitFormals T_identifier ':' '.' '\"' ':' Expr
719 $$->seenNamed_ = true;
720 typedef typeof $$->exprs_ ListType;
721 size_t ** pos = new size_t * ( 0 );
722 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, strdup( $2 ), $7 );
723 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
730 : '\\' Formals T_mapsto FunctionModeList Expr
732 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
733 Ast::FunctionFunction * res = new Ast::FunctionFunction( @$, $2, $5, $4 );
734 res->push_exprs( args );
735 $$ = new Ast::CallExpr( @$,
736 RefCountPtr< const Lang::Function >( res ),
739 | '(' OperatorFunction ')'
748 $$ = new list< RefCountPtr< const char > >( );
750 | OneOrMoreOrderedFormals
753 OneOrMoreOrderedFormals
756 $$ = new list< RefCountPtr< const char > >( );
757 $$->push_back( strrefdup( $1 ) );
759 | OneOrMoreOrderedFormals T_identifier
762 $$->push_back( strrefdup( $2 ) );
769 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_MINUSMINUS ) );
773 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_PLUSPLUS ) );
777 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_AMPERSAND ) );
781 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_PLUS ) );
785 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_MINUS ) );
789 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_STAR ) );
793 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_SLASH ) );
797 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_PROJECTION ) );
801 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_ANGLE ) );
805 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_AMPERSAND_MORE ) );
809 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_NEG ) );
813 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_COMPOSE ) );
817 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_LESS ) );
821 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_GREATER ) );
825 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_EQEQ ) );
829 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_EQNEQ ) );
833 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_LESSEQ ) );
837 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_GREATEREQ ) );
841 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_NOT ) );
845 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_FUNCTION_AND ) );
849 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_FUNCTION_OR ) );
853 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_XOR ) );
858 : ExprExceptConstStrings
861 $$ = new Ast::Constant( @1, $1 );
865 ExprExceptConstStrings
866 : ConstantExceptStrings
869 | '(' T_tex ExprExceptConstStrings ')'
871 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
872 args->orderedExprs_->push_back( $3 );
873 $$ = new Ast::CallExpr( @$,
874 Ast::THE_FUNCTION_TeX,
877 | '(' T_tex T_string ')'
879 Kernel::theTeXLabelManager.announce( std::string( $3->val_.getPtr( ) ), @3 );
880 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
881 args->orderedExprs_->push_back( new Ast::Constant( @3, $3 ) );
882 $$ = new Ast::CallExpr( @$,
883 Ast::THE_FUNCTION_TeX,
889 $$->immediate_ = true;
894 | SuperMemberReference
902 $$ = new Ast::NegExpr( @$, @2, $3 );
906 $$ = new Ast::RelativeExpr( @$, @2, $3 );
910 $$ = new Ast::EmptyExpression( @$ );
912 | '(' Expr T_llthan InsertionSequence ')'
914 std::list< Ast::Node * > * bracket = new std::list< Ast::Node * >( );
916 size_t ** pos = new size_t * ( 0 );
917 Ast::StateReference * dst = new Ast::LexiographicState( @2, strdup( Kernel::SEQUENTIAL_EXPR_VAR_ID ), new Kernel::Environment::LexicalKey * ( 0 ) );
919 bracket->push_back( new Ast::IntroduceState( @3,
920 strdup( Kernel::SEQUENTIAL_EXPR_VAR_ID ),
923 for( std::list< Ast::Expression * >::const_iterator i = $4->begin( ); i != $4->end( ); ++i )
925 bracket->push_back( new Ast::Insertion( dst, *i ) );
927 bracket->push_back( new Ast::Freeze( @3, strdup( Kernel::SEQUENTIAL_EXPR_VAR_ID ), pos ) );
928 $$ = new Ast::CodeBracket( @$, bracket );
932 $$ = new Ast::EvalOutsideExpr( @$, $2 );
939 Kernel::Environment::LexicalKey ** key = new Kernel::Environment::LexicalKey * ( 0 );
940 $$ = new Ast::LexiographicVariable( @$, $1, key );
944 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
945 Ast::EvalSymbolFunction * res = new Ast::EvalSymbolFunction( @$, $2 );
946 res->push_exprs( args );
947 $$ = new Ast::CallExpr( @$,
948 RefCountPtr< const Lang::Function >( res ),
951 | T_dynamic_identifier
953 $$ = new Ast::DynamicVariable( @$, $1 );
955 | '(' StateReference ')'
957 $$ = new Ast::Peek( @$, $2 );
960 | Expr '.' T_identifier
962 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
963 Ast::MemberReferenceFunction * res = new Ast::MemberReferenceFunction( @$, $1, $3 );
964 res->push_exprs( args );
965 $$ = new Ast::CallExpr( @$,
966 RefCountPtr< const Lang::Function >( res ),
969 | Expr '.' MethodIdentifier
971 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
972 Ast::PublicMethodReferenceFunction * res = new Ast::PublicMethodReferenceFunction( @$, $1, $3 );
973 res->push_exprs( args );
974 $$ = new Ast::CallExpr( @$,
975 RefCountPtr< const Lang::Function >( res ),
979 | '(' T_esc_continuation T_identifier Expr ')'
981 $$ = new Ast::LetDynamicECExpr( @$, @3, $3, $4 );
983 | '(' T_esc_continue T_identifier Expr ')'
985 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
986 Ast::ContinueDynamicECFunction * res = new Ast::ContinueDynamicECFunction( @3, $3, $4 );
987 res->push_exprs( args );
988 $$ = new Ast::CallExpr( @$,
989 RefCountPtr< const Lang::Function >( res ),
991 /* This used to be immediate, but right now that seems utterly wrong!
992 * Imagine choosing between two continuations; then both continuations would require invokation before being "passed" to the <if> function.
993 * On the other hand, I can admit that it seems a bit uncanny to let the <if> function return the continuation invokations as thunks, not
994 * knowing when they will be forced... But I don't think there's a choice here anyway; this expression can't be immediate.
997 | '(' T_esc_backtrace T_identifier ')'
999 $$ = new Ast::GetECBacktraceExpr( @3, $3 );
1001 | '(' T_indexof T_identifier ')'
1003 $$ = new Ast::LexicalVariableLocationExpr( @3, $3, Ast::LexicalVariableLocationExpr::INDEX );
1005 | '(' T_depthof T_identifier ')'
1007 $$ = new Ast::LexicalVariableLocationExpr( @3, $3, Ast::LexicalVariableLocationExpr::DEPTH );
1011 $$ = new Ast::LexicalVariableNameExpr( @1 );
1013 | T_absLeft Expr T_absRight
1015 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1016 args->orderedExprs_->push_back( $2 );
1017 $$ = new Ast::CallExpr( @$,
1018 Lang::THE_FUNCTION_ABS,
1023 $$ = new Ast::WithDynamicExpr( @$, $1, $3 );
1025 | T_unionLeft ArgList T_unionRight
1027 $$ = new Ast::UnionExpr( @$, $2 );
1029 | Expr T_minusminus T_cycle
1031 $$ = new Ast::CycleExpr( @3, $1 );
1033 | Expr T_minusminus Expr
1035 $$ = new Ast::MinusMinusExpr( @2, $1, $3 );
1037 | Expr T_plusplus Expr
1039 $$ = new Ast::PlusPlusExpr( @2, $1, $3 );
1043 $$ = new Ast::AmpersandExpr( @2, $1, $3 );
1047 $$ = new Ast::PlusExpr( @2, $1, $3 );
1051 $$ = new Ast::MinusExpr( @2, $1, $3 );
1055 $$ = new Ast::AngleExpr( @2, $1, $3 );
1057 | Expr T_ampersandMore Expr
1059 $$ = new Ast::AmpersandMoreExpr( @2, $1, $3 );
1063 $$ = new Ast::StarExpr( @2, $1, $3 );
1065 | Expr T_projection Expr
1067 $$ = new Ast::ProjectionExpr( @2, $1, $3 );
1071 $$ = new Ast::SlashExpr( @2, $1, $3 );
1075 $$ = new Ast::NegExpr( @1, $2 );
1077 | Expr T_compose Expr
1079 $$ = new Ast::ComposeExpr( @2, $1, $3 );
1083 $$ = new Ast::LessExpr( @2, $1, $3 );
1087 $$ = new Ast::GreaterExpr( @2, $1, $3 );
1091 $$ = new Ast::EqualExpr( @2, $1, $3 );
1095 $$ = new Ast::NotEqualExpr( @2, $1, $3 );
1097 | Expr T_lesseq Expr
1099 $$ = new Ast::LessEqualExpr( @2, $1, $3 );
1101 | Expr T_greatereq Expr
1103 $$ = new Ast::GreaterEqualExpr( @2, $1, $3 );
1107 $$ = new Ast::NotExpr( @1, $2 );
1111 // $$ = new Ast::AndExpr( @2, $1, $3 );
1113 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1114 args->orderedExprs_->push_back( $1 );
1115 args->orderedExprs_->push_back( $3 );
1116 $$ = new Ast::CallExpr( @$,
1117 Lang::THE_FUNCTION_AND,
1122 // $$ = new Ast::OrExpr( @2, $1, $3 );
1124 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1125 args->orderedExprs_->push_back( $1 );
1126 args->orderedExprs_->push_back( $3 );
1127 $$ = new Ast::CallExpr( @$,
1128 Lang::THE_FUNCTION_OR,
1133 $$ = new Ast::XorExpr( @2, $1, $3 );
1137 Kernel::Environment::LexicalKey ** key = new Kernel::Environment::LexicalKey * ( 0 );
1138 $$ = new Ast::LexiographicType( @$, $1, key );
1144 : T_dynamic_identifier ':' Expr %prec T_dynamiccolon
1146 $$ = new Ast::DynamicBindingExpression( @1, $1, $3, new Kernel::Environment::LexicalKey * ( 0 ) );
1148 | T_dynamic_identifier ':' T_dynamic Expr %prec T_dynamiccolon
1150 $$ = new Ast::DynamicBindingExpression( @1, $1,
1151 new Ast::DynamicExpression( @4, $4 ),
1152 new Kernel::Environment::LexicalKey * ( 0 ) );
1154 | T_dynamic_state_identifier ':' StateReference %prec T_dynamiccolon
1156 $$ = new Ast::DynamicStateBindingExpression( @1, @1, $1, $3 );
1161 ConstantExceptStrings
1164 $$ = new Ast::Constant( @1, new Lang::Integer( $1 ) );
1168 $$ = new Ast::Constant( @1, new Lang::Float( $1 ) );
1172 $$ = new Ast::Constant( @1, new Lang::Length( $1 ) );
1176 $$ = new Ast::Constant( @1, new Lang::Boolean( $1 ) );
1180 $$ = new Ast::Constant( @$, new Lang::Symbol( $2 ) );
1187 $$ = new Ast::CodeBracket( @$, $2 );
1194 $$ = $1; // Explicit upcast avoids bison warning.
1196 | T_identifier ':' Expr
1198 size_t ** pos = new size_t * ( 0 );
1199 $$ = new Ast::DefineVariable( @1, $1, $3, pos );
1201 | T_state_identifier ':' Expr
1203 size_t ** pos = new size_t * ( 0 );
1204 $$ = new Ast::IntroduceState( @1, $1, $3, pos );
1206 | T_state_identifier ';'
1208 size_t ** pos = new size_t * ( 0 );
1209 $$ = new Ast::Freeze( @1, $1, pos );
1211 | T_identifier ':' T_state_identifier ';'
1213 size_t ** posVar = new size_t * ( 0 );
1214 size_t ** posState = new size_t * ( 0 );
1215 $$ = new Ast::DefineVariable( @1, $1, new Ast::Freeze( @3, $3, posState ), posVar );
1217 | T_dynamic T_dynamic_identifier Expr Expr
1219 $$ = new Ast::DynamicVariableDecl( @$, @2, $2, $3, $4 );
1221 | T_dynamic T_dynamic_identifier Expr T_dynamic Expr
1223 $$ = new Ast::DynamicVariableDecl( @$, @2, $2, $3,
1224 new Ast::DynamicExpression( @5, $5 ) );
1226 | T_dynamic T_dynamic_state_identifier StateReference
1228 $$ = new Ast::DynamicStateDecl( @$, @2, $2, $3, new size_t * ( 0 ) );
1230 | Expr '.' T_identifier T_llthan InsertionSequence
1232 shapeserror( "MemberInsertionSequence not implemented" );
1233 // $$ = new Ast::MemberInsertionSequence( @$, $1, $3, $5 );
1235 | '(' '#' Expr ')' '.' T_identifier T_llthan InsertionSequence
1237 shapeserror( "ProtectedMemberInsertionSequence not implemented" );
1238 // $$ = new Ast::ProtectedMemberInsertionSequence( @$, @2, $3, $6, $8 );
1242 $$ = new Ast::SourceLocationMark( @$ );
1249 $$ = new std::list< Ast::Expression * >( );
1250 $$->push_back( $1 );
1252 | InsertionSequence T_llthan Expr
1255 $$->push_back( $3 );
1262 $$ = new list< Ast::Node * >( );
1263 $$->push_back( $1 );
1265 | OneOrMoreGroupElems GroupElem
1268 $$->push_back( $2 );
1270 | StateReference T_llthan InsertionSequence
1272 $$ = new list< Ast::Node * >( );
1273 for( std::list< Ast::Expression * >::const_iterator i = $3->begin( ); i != $3->end( ); ++i )
1275 $$->push_back( new Ast::Insertion( $1, *i ) );
1278 | OneOrMoreGroupElems StateReference T_llthan InsertionSequence
1281 for( std::list< Ast::Expression * >::const_iterator i = $4->begin( ); i != $4->end( ); ++i )
1283 $$->push_back( new Ast::Insertion( $2, *i ) );
1286 | T_splitLeft SplitFormals T_splitRight ':' Expr
1288 $$ = new list< Ast::Node * >( );
1289 size_t ** pos = new size_t * ( 0 );
1291 $5->immediate_ = true;
1292 $$->push_back( new Ast::DefineVariable( @5, $2->newSplitVarId( ), $5, pos ) );
1294 size_t orderedCount = 0;
1296 typedef typeof $2->exprs_ ListType;
1297 for( ListType::iterator i = $2->exprs_.begin( ); i != $2->exprs_.end( ); ++i )
1299 i->second->setStruct( @5, pos );
1300 $$->push_back( i->first );
1301 if( i->second->isOrdered( ) )
1307 if( $2->sinkDefine_ != 0 )
1309 $2->sinkExpr_->setStruct( @5, pos, orderedCount );
1310 $$->push_back( $2->sinkDefine_ );
1314 $$->push_back( new Ast::AssertNoSinkNeeded( @2, orderedCount, @5, pos ) );
1317 | T_splitLeft SplitFormals T_splitRight Expr
1319 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @4, strrefdup( "Expected ':'." ) ) );
1320 $$ = new list< Ast::Node * >( );
1321 $$->push_back( new Ast::ErrorExpression( @$ ) );
1323 | OneOrMoreGroupElems T_splitLeft SplitFormals T_splitRight ':' Expr
1326 size_t ** pos = new size_t * ( 0 );
1328 $6->immediate_ = true;
1329 $$->push_back( new Ast::DefineVariable( @6, $3->newSplitVarId( ), $6, pos ) );
1331 size_t orderedCount = 0;
1333 typedef typeof $3->exprs_ ListType;
1334 for( ListType::iterator i = $3->exprs_.begin( ); i != $3->exprs_.end( ); ++i )
1336 i->second->setStruct( @6, pos );
1337 $$->push_back( i->first );
1338 if( i->second->isOrdered( ) )
1344 if( $3->sinkDefine_ != 0 )
1346 $3->sinkExpr_->setStruct( @6, pos, orderedCount );
1347 $$->push_back( $3->sinkDefine_ );
1351 $$->push_back( new Ast::AssertNoSinkNeeded( @3, orderedCount, @6, pos ) );
1354 | OneOrMoreGroupElems T_splitLeft SplitFormals T_splitRight Expr
1356 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @4, strrefdup( "Expected ':'." ) ) );
1358 $$->push_back( new Ast::ErrorExpression( @$ ) );
1365 $$ = new list< Ast::Node * >( );
1367 | OneOrMoreGroupElems
1371 SuperMemberReference
1372 : '(' '#' Expr ')' '.' T_identifier
1374 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1375 Ast::ProtectedMemberReferenceFunction * res = new Ast::ProtectedMemberReferenceFunction( @$, @2, $3, @6, $6 );
1376 res->push_exprs( args );
1377 $$ = new Ast::CallExpr( @$,
1378 RefCountPtr< const Lang::Function >( res ),
1385 : T_identifier '#' T_identifier
1387 Kernel::Environment::LexicalKey ** key = new Kernel::Environment::LexicalKey * ( 0 );
1388 $$ = new Ast::MethodIdExpr( @$, new Ast::LexiographicVariable( @1, $1, key ), $3 );
1394 : '[' '(' '#' Expr ')' '.' MethodIdentifier ArgList ']'
1396 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1397 Ast::ProtectedMethodReferenceFunction * res = new Ast::ProtectedMethodReferenceFunction( @$, @3, $4, $7 );
1398 res->push_exprs( args );
1399 $$ = new Ast::CallExpr( @$,
1400 new Ast::CallExpr( @3,
1401 RefCountPtr< const Lang::Function >( res ),
1405 | '[' '(' '#' ')' '.' MethodIdentifier ArgList ']'
1407 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1408 Ast::ProtectedMethodReferenceFunction * res = new Ast::ProtectedMethodReferenceFunction( @$, @3, 0, $6 );
1409 res->push_exprs( args );
1410 $$ = new Ast::CallExpr( @$,
1411 new Ast::CallExpr( @3,
1412 RefCountPtr< const Lang::Function >( res ),
1420 : '[' T_class '(' Expr Formals ')' T_identifier '(' ListOfParentsWithInitargs ')'
1425 DeleteOnExit< char > isaDeleter( $7 );
1426 if( strcmp( $7, "isa" ) != 0 )
1428 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @7, strrefdup( "Expected \"isa\"." ) ) );
1430 if( ( $11 & Ast::CLASS_MODE_ABSTRACT ) != 0 && ( $11 & Ast::CLASS_MODE_FINAL ) != 0 )
1432 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @11, strrefdup( "Declaring a class both abstract and final is forbidden." ) ) );
1435 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1436 Ast::ClassFunction * res = new Ast::ClassFunction( @$, $4, $5, $9, $11, $12 );
1437 res->push_exprs( args );
1438 $$ = new Ast::CallExpr( @$,
1439 RefCountPtr< const Lang::Function >( res ),
1444 ListOfParentsWithInitargs
1445 : '(' Expr ArgList ')'
1447 $$ = new std::list< const Ast::CallExpr * >;
1448 $$->push_back( new Ast::CallExpr( @$, $2, $3 ) );
1450 | ListOfParentsWithInitargs '(' Expr ArgList ')'
1453 $$->push_back( new Ast::CallExpr( Ast::SourceLocation( @2, @5 ), $3, $4 ) );
1462 | OneOrMoreClassModeSpecifiers
1465 OneOrMoreClassModeSpecifiers
1466 : ClassModeSpecifier
1467 | OneOrMoreClassModeSpecifiers ClassModeSpecifier
1476 DeleteOnExit< char > strDeleter( $1 );
1478 if( strcmp( $1, "abstract" ) == 0 )
1480 $$ = Ast::CLASS_MODE_ABSTRACT;
1482 else if( strcmp( $1, "final" ) == 0 )
1484 $$ = Ast::CLASS_MODE_FINAL;
1488 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @$, strrefdup( "This is not a valid class mode specifier" ) ) );
1496 $$ = new std::list< Ast::ClassSection * >;
1498 | OneOrMoreClassSections
1501 OneOrMoreClassSections
1504 $$ = new std::list< Ast::ClassSection * >;
1505 $$->push_back( $1 );
1507 | OneOrMoreClassSections ClassSection
1510 $$->push_back( $2 );
1515 : '(' T_members MemberDeclarations ')'
1519 | '(' T_prepare Group ')'
1521 $$ = new Ast::PrepareSection( @$, $3 );
1523 | '(' T_identifier MethodDeclarations ')'
1525 DeleteOnExit< char > accessSpecDeleter( $2 );
1526 unsigned int accessSpec = 0;
1527 if( strcmp( $2, "__methods__" ) == 0 )
1529 accessSpec = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET;
1531 else if( strcmp( $2, "__abstract__" ) == 0 )
1533 accessSpec = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_ABSTRACT;
1535 else if( strcmp( $2, "__final__" ) == 0 )
1537 accessSpec = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_FINAL;
1539 else if( strcmp( $2, "__protected__" ) == 0 )
1541 accessSpec = Ast::MEMBER_ACCESS_PROTECTED_GET;
1543 else if( strcmp( $2, "__private__" ) == 0 )
1549 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "This is not a valid method access specifier." ) ) );
1551 $3->addModeBits( accessSpec );
1554 | '(' T_abstract OrderedFormals ')'
1556 $$ = new Ast::AbstractSection( @$, $3 );
1558 | '(' T_overrides Expr T_gr__ MethodDeclarations ')'
1560 $$ = new Ast::OverridesSection( $3, $5 );
1567 $$ = new Ast::MemberSection;
1569 | OneOrMoreMemberDeclarations
1572 OneOrMoreMemberDeclarations
1575 $$ = new Ast::MemberSection;
1576 $$->push_back( $1 );
1578 | OneOrMoreMemberDeclarations MemberDeclaration
1581 $$->push_back( $2 );
1586 : '(' T_identifier Expr ')'
1588 $$ = new Ast::MemberDeclaration( @$, $2, $3, 0 );
1590 | '(' T_identifier Expr MemberAccessList ')'
1592 $$ = new Ast::MemberDeclaration( @$, $2, $3, $4 );
1597 : MemberAccessSpecifier
1598 | MemberAccessList MemberAccessSpecifier
1604 MemberAccessSpecifier
1607 $$ = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET;
1611 $$ = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PUBLIC_INSERT | Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_ACCESS_PROTECTED_INSERT;
1615 $$ = Ast::MEMBER_ACCESS_PROTECTED_GET;
1617 | '(' '#' T_llthan ')'
1619 $$ = Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_ACCESS_PROTECTED_INSERT;
1623 $$ = Ast::MEMBER_TRANSFORMING;
1630 $$ = new Ast::MemberSection;
1632 | OneOrMoreMethodDeclarations
1635 OneOrMoreMethodDeclarations
1638 $$ = new Ast::MemberSection;
1639 $$->push_back( $1 );
1641 | OneOrMoreMethodDeclarations MethodDeclaration
1644 $$->push_back( $2 );
1649 : '(' T_identifier Expr ')'
1651 $$ = new Ast::MemberDeclaration( @$, $2, $3, Ast::MEMBER_CONST | Ast::MEMBER_METHOD );
1653 | '(' '[' T_identifier Formals ']' FunctionModeList GroupElem ')'
1655 Ast::Expression * body = dynamic_cast< Ast::Expression * >( $7 );
1658 std::list< Ast::Node * > * bracket = new std::list< Ast::Node * >( );
1659 bracket->push_back( $7 );
1660 body = new Ast::CodeBracket( @7, bracket );
1662 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1663 Ast::FunctionFunction * res = new Ast::FunctionFunction( @$, $4, body, $6 );
1664 res->push_exprs( args );
1665 $$ = new Ast::MemberDeclaration( @$, $3, new Ast::CallExpr( @$,
1666 RefCountPtr< const Lang::Function >( res ),
1668 Ast::MEMBER_CONST | Ast::MEMBER_METHOD | ( (($6 & Ast::FUNCTION_TRANSFORMING) != 0) ? Ast::MEMBER_TRANSFORMING : 0 ) );
1677 | OneOrMoreFunctionModeSpecifiers
1680 OneOrMoreFunctionModeSpecifiers
1681 : FunctionModeSpecifier
1682 | OneOrMoreFunctionModeSpecifiers FunctionModeSpecifier
1688 FunctionModeSpecifier
1691 $$ = Ast::FUNCTION_TRANSFORMING;
1704 /* The closing %% above marks the end of the Rules section and the beginning
1705 * of the User Subroutines section. All text from here to the end of the
1706 * file is copied verbatim to the end of the generated y.tab.c file.
1707 * This section is where you put definitions of helper functions.