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, 2010 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;
127 Lang::String * Lang_String;
128 std::list< const Ast::CallExpr * > * callExprList;
129 std::list< Ast::ClassSection * > * classSectionList;
130 Ast::ClassSection * classSection;
131 Ast::MemberSection * memberSection;
132 Ast::MemberDeclaration * memberDeclaration;
133 Ast::StateReference * stateReference;
134 Ast::MemberMode memberMode;
135 Ast::ClassMode classMode;
136 Ast::FunctionMode functionMode;
143 * Here we tell yacc about all the token types that we are using.
144 * Yacc will assign unique numbers to these and export the #define
145 * in the generated y.tab.h header file.
148 %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
149 %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
150 %token <tokenID> T_indexof T_depthof T_variableName T_dynamic T_continuation T_continue T_esc_continuation T_esc_continue T_esc_backtrace T_last
151 %token <tokenID> T_class T_members T_prepare T_abstract T_overrides T_gr__
152 %token <tokenID> T_split T_splitLeft T_splitRight T_unionLeft T_unionRight T_absLeft T_absRight
153 %token <tokenID> T_srcLoc
154 %token <tokenID> T_interactiveMark
156 %token <intVal> T_int
157 %token <uintVal> T_char
158 %token <floatVal> T_float T_length
159 %token <expr> T_speciallength
160 %token <boolVal> T_bool
161 %token <char_p> T_identifier_except_tex T_identifier_tex T_dynamic_identifier T_state_identifier T_dynamic_state_identifier T_symbol T_typename
162 %token <Lang_String> T_string
164 /* Non-terminal types
166 * In order for yacc to assign/access the correct field of $$, $1, we
167 * must to declare which field is appropriate for the non-terminal.
168 * As an example, this first type declaration establishes that the DeclList
169 * non-terminal uses the field named "declList" in the yylval union. This
170 * means that when we are setting $$ for a reduction for DeclList ore reading
171 * $n which corresponds to a DeclList nonterminal we are accessing the field
172 * of the union named "declList" which is of type List<Decl*>.
173 * pp2: You'll need to add many of these of your own.
176 %type <expr> Program Expr ExprExceptConstStrings ConstantExceptStrings
177 %type <expr> DynamicBinding CallExpr CurryCallExpr MutateExpr MutatorCallbackExpr Function OperatorFunction Class Coords PolarHandle
178 %type <expr> CodeBracket SuperCall SuperMemberReference
179 %type <exprList> InsertionSequence
180 %type <node> GroupElem
181 %type <nodeList> Group OneOrMoreGroupElems
182 %type <strList> OrderedFormals OneOrMoreOrderedFormals
183 %type <formals> Formals OneOrMoreFormalsItems
184 // %type <formalsList> NamedFormalsWithOrder OneOrMoreNamedFormalsWithOrder
185 %type <argList> ArgList OneOrMoreArgListItems
186 %type <methodId> MethodIdentifier
187 %type <callExprList> ListOfParentsWithInitargs;
188 %type <classSectionList> ClassSections OneOrMoreClassSections
189 %type <classSection> ClassSection
190 %type <memberSection> MemberDeclarations OneOrMoreMemberDeclarations
191 %type <memberSection> MethodDeclarations OneOrMoreMethodDeclarations
192 %type <memberDeclaration> MemberDeclaration MethodDeclaration
193 %type <memberMode> MemberAccessList MemberAccessSpecifier
194 %type <classMode> ClassModeList ClassModeSpecifier OneOrMoreClassModeSpecifiers
195 %type <functionMode> FunctionModeList OneOrMoreFunctionModeSpecifiers FunctionModeSpecifier
197 %type <stateReference> StateReference
198 %type <splitFormals> SplitFormals OneOrMoreSplitFormals
199 %type <char_p> Identifier
201 %nonassoc T_assign ':'
208 %left T_emptybrackets T_dddotbrackets T_ggthan
210 %left T_ampersandMore
212 %nonassoc T_dynamiccolon
218 %nonassoc T_eqeq T_eqneq T_lesseq T_greatereq
220 %left T_plusplus T_minusminus
225 %left '*' '/' T_projection
233 %left T_atat T_surrounding
239 %name-prefix="shapes"
243 * All productions and actions should be placed between the start and stop
244 * %% markers which delimit the Rules section.
248 : Group T_preludesep Group T_EOF
250 /* Note that the source location of the prelude is discarded. */
251 $1->push_back( new Ast::CodeBracket( @3, $3 ) );
252 $$ = new Ast::CodeBracket( @3, $1 );
253 Ast::theProgram = $$;
256 | T_interactiveMark Group T_EOF
258 Ast::theInteractiveInput = $2;
263 shapeserror( "Expecting end of file." );
269 : '(' Expr ',' Expr ')'
271 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
272 args->orderedExprs_->push_back( $2 );
273 args->orderedExprs_->push_back( $4 );
274 $$ = new Ast::CallExpr( @$,
275 Ast::THE_FUNCTION_coords2D,
278 | '(' Expr ',' Expr '^' Expr ')'
280 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
281 args->orderedExprs_->push_back( $2 );
282 args->orderedExprs_->push_back( $4 );
283 args->orderedExprs_->push_back( $6 );
284 $$ = new Ast::CallExpr( @$,
285 Ast::THE_FUNCTION_cornercoords2D,
288 | '(' Expr ',' Expr '^' ')'
290 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
291 args->orderedExprs_->push_back( $2 );
292 args->orderedExprs_->push_back( $4 );
293 $$ = new Ast::CallExpr( @$,
294 Ast::THE_FUNCTION_cornercoords2D,
297 | '(' Expr ',' Expr ',' Expr ')'
299 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
300 args->orderedExprs_->push_back( $2 );
301 args->orderedExprs_->push_back( $4 );
302 args->orderedExprs_->push_back( $6 );
303 $$ = new Ast::CallExpr( @$,
304 Ast::THE_FUNCTION_coords3D,
311 : '(' Expr '^' Expr ')'
313 $$ = new Ast::PolarHandle2DExpr( @$, $2, $4 );
317 $$ = new Ast::PolarHandle2DExprFree_a( @$, $2 );
321 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
322 args->orderedExprs_->push_back( $3 );
323 $$ = new Ast::CallExpr( @$,
324 Ast::THE_FUNCTION_polarHandle2DFree_r,
329 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
330 $$ = new Ast::CallExpr( @$,
331 Ast::THE_FUNCTION_polarHandle2DFree_ra,
339 $$ = new Ast::LexiographicState( @1, $1, new Kernel::Environment::LexicalKey * ( 0 ) );
341 | T_dynamic_state_identifier
343 $$ = new Ast::DynamicState( @1, $1 );
350 $$ = new Ast::ArgListExprs( true );
352 | OneOrMoreArgListItems
355 OneOrMoreArgListItems
358 $$ = new Ast::ArgListExprs( true );
359 $$->orderedExprs_->push_back( $1 );
363 $$ = new Ast::ArgListExprs( true );
364 $$->orderedStates_->push_back( $1 );
366 | Identifier ':' Expr
368 $$ = new Ast::ArgListExprs( true );
369 (*$$->namedExprs_)[ $1 ] = $3;
371 | T_state_identifier ':' StateReference
373 $$ = new Ast::ArgListExprs( true );
374 (*$$->namedStates_)[ $1 ] = $3;
376 | OneOrMoreArgListItems Expr
379 if( ! $$->namedExprs_->empty( ) )
381 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Unnamed expressions may not appear among named expressions." ) ) );
383 $$->orderedExprs_->push_back( $2 );
385 | OneOrMoreArgListItems StateReference
388 if( ! $$->namedStates_->empty( ) )
390 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Unnamed states may not appear among named states." ) ) );
392 $$->orderedStates_->push_back( $2 );
394 | OneOrMoreArgListItems Identifier ':' Expr
397 if( $$->namedExprs_->find( $2 ) != $$->namedExprs_->end( ) )
399 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
401 (*$$->namedExprs_)[ $2 ] = $4;
403 | OneOrMoreArgListItems T_state_identifier ':' StateReference
406 if( $$->namedStates_->find( $2 ) != $$->namedStates_->end( ) )
408 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
410 (*$$->namedStates_)[ $2 ] = $4;
416 : '[' Expr ArgList ']'
418 $$ = new Ast::CallExpr( @$, $2, $3 );
420 | Expr T_emptybrackets Expr
422 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
423 args->orderedExprs_->push_back( $3 );
424 $$ = new Ast::CallExpr( @$,
430 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
431 args->orderedExprs_->push_back( $1 );
432 $$ = new Ast::CallExpr( @$,
436 | Expr T_emptybrackets Split
438 $$ = new Ast::CallSplitExpr( @$,
442 | Expr T_dddotbrackets Expr
444 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
445 args->orderedExprs_->push_back( $3 );
446 $$ = new Ast::CallExpr( @$,
449 true ); /* true means Curry */
451 | Expr T_dddotbrackets Identifier ':' Expr %prec T_dynamiccolon
453 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
454 (*args->namedExprs_)[ $3 ] = $5;
455 $$ = new Ast::CallExpr( @$,
458 true ); /* true means Curry */
460 | Expr T_dddotbrackets Split
462 $$ = new Ast::CallSplitExpr( @$,
465 true ); /* true means Curry */
471 : '[' Expr ArgList T_dddot ']'
473 $$ = new Ast::CallExpr( @$, $2, $3, true ); /* true means Curry */
475 | '(' MutatorCallbackExpr ')'
482 : '.' '[' Identifier ArgList ']'
484 Kernel::Formals * stateFormal = new Kernel::Formals( );
485 stateFormal->stateOrder_->insert( std::pair< const char *, size_t >( Kernel::MUTATOR_CURRY_VAR_ID, stateFormal->stateOrder_->size( ) ) );
486 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
487 Ast::StateReference * stateref = new Ast::LexiographicState( @2, strdup( Kernel::MUTATOR_CURRY_VAR_ID ), new Kernel::Environment::LexicalKey * ( 0 ) );
488 Ast::CallExpr * body =
489 new Ast::CallExpr( @$,
490 new Ast::MutatorReference( @1, stateref, $3 ),
492 body->setMutatorSelf( stateref );
493 Ast::FunctionFunction * res = new Ast::FunctionFunction( @$, stateFormal, body, 0 );
494 res->push_exprs( args );
495 $$ = new Ast::CallExpr( @$,
496 RefCountPtr< const Lang::Function >( res ),
502 : StateReference '.' '[' Identifier ArgList ']'
504 Ast::CallExpr * res =
505 new Ast::CallExpr( @$,
506 new Ast::MutatorReference( @4, $1, $4 ),
508 res->setMutatorSelf( $1 );
516 $$ = new Kernel::Formals( );
521 $$ = new Kernel::Formals( );
522 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $2, $$->defaultExprs_.size( ) ) );
523 /* Note that we do not push a default expression (not even a null pointer) for the sink.
524 * This way, the length of defaultExprs_ allways gives the number of non-sink arguments.
525 * The default value for the sink is taken care of in a non-standard way anyway.
530 | OneOrMoreFormalsItems
535 | OneOrMoreFormalsItems T_split Identifier
538 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $3, $$->defaultExprs_.size( ) ) );
539 /* Note that we do not push a default expression (not even a null pointer) for the sink.
540 * This way, the length of defaultExprs_ allways gives the number of non-sink arguments.
541 * The default value for the sink is taken care of in a non-standard way anyway.
548 OneOrMoreFormalsItems
551 $$ = new Kernel::Formals( );
552 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $1, $$->defaultExprs_.size( ) ) );
553 $$->defaultExprs_.push_back( 0 );
555 | Identifier ':' Expr
557 $$ = new Kernel::Formals( );
558 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $1, $$->defaultExprs_.size( ) ) );
559 $$->defaultExprs_.push_back( $3 );
563 $$ = new Kernel::Formals( );
564 $$->stateOrder_->insert( std::pair< const char *, size_t >( $1, $$->stateOrder_->size( ) ) );
566 | OneOrMoreFormalsItems Identifier
569 if( $$->seenDefault_ )
571 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Order-based formals may not appear among named formals." ) ) );
573 if( $$->argumentOrder_->find( $2 ) != $$->argumentOrder_->end( ) )
575 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
577 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $2, $$->defaultExprs_.size( ) ) );
578 $$->defaultExprs_.push_back( 0 );
580 | OneOrMoreFormalsItems Identifier ':' Expr
583 $$->seenDefault_ = true;
584 if( $$->argumentOrder_->find( $2 ) != $$->argumentOrder_->end( ) )
586 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
588 $$->argumentOrder_->insert( std::pair< const char *, size_t >( $2, $$->defaultExprs_.size( ) ) );
589 $$->defaultExprs_.push_back( $4 );
591 | OneOrMoreFormalsItems T_state_identifier
594 if( $$->stateOrder_->find( $2 ) != $$->stateOrder_->end( ) )
596 Ast::theAnalysisErrorsList.push_back( new Exceptions::RepeatedFormal( @2, $2 ) );
598 $$->stateOrder_->insert( std::pair< const char *, size_t >( $2, $$->stateOrder_->size( ) ) );
606 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @$, strrefdup( "The list of split assignment variables must not be empty." ) ) );
607 $$ = new Ast::SplitDefineVariables( );
611 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @$, strrefdup( "Just a sink in a split assignment formals list makes no sense." ) ) );
612 $$ = new Ast::SplitDefineVariables( );
614 | OneOrMoreSplitFormals
618 | OneOrMoreSplitFormals T_split Identifier
621 Ast::StructSplitSink * expr = new Ast::StructSplitSink( );
622 size_t ** pos = new size_t * ( 0 );
623 $$->sinkDefine_ = new Ast::DefineVariable( @3, $3, expr, pos );
624 $$->sinkExpr_ = expr;
628 OneOrMoreSplitFormals
631 $$ = new Ast::SplitDefineVariables( );
632 typedef typeof $$->exprs_ ListType;
633 size_t ** pos = new size_t * ( 0 );
634 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @1, static_cast< size_t >( 0 ), 0 );
635 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
638 | Identifier ':' Expr
640 $$ = new Ast::SplitDefineVariables( );
641 typedef typeof $$->exprs_ ListType;
642 size_t ** pos = new size_t * ( 0 );
643 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @1, static_cast< size_t >( 0 ), $3 );
644 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
647 | Identifier ':' '.' Identifier
649 $$ = new Ast::SplitDefineVariables( );
650 typedef typeof $$->exprs_ ListType;
651 size_t ** pos = new size_t * ( 0 );
652 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, $4, 0 );
653 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
656 | Identifier ':' '.' Identifier ':' Expr
658 $$ = new Ast::SplitDefineVariables( );
659 typedef typeof $$->exprs_ ListType;
660 size_t ** pos = new size_t * ( 0 );
661 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, $4, $6 );
662 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
665 | Identifier ':' '.' '\"'
667 $$ = new Ast::SplitDefineVariables( );
668 typedef typeof $$->exprs_ ListType;
669 size_t ** pos = new size_t * ( 0 );
670 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, strdup( $1 ), 0 );
671 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
674 | Identifier ':' '.' '\"' ':' Expr
676 $$ = new Ast::SplitDefineVariables( );
677 typedef typeof $$->exprs_ ListType;
678 size_t ** pos = new size_t * ( 0 );
679 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @4, strdup( $1 ), $6 );
680 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @1, $1, ref, pos ),
683 | OneOrMoreSplitFormals Identifier
688 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Order-based formals may not appear among named formals." ) ) );
690 if( $$->seenDefault_ )
692 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "All order-based formals without default values must be placed before those with default values." ) ) );
694 typedef typeof $$->exprs_ ListType;
695 size_t ** pos = new size_t * ( 0 );
696 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @2, $$->exprs_.size( ), 0 );
697 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
700 | OneOrMoreSplitFormals Identifier ':' Expr
705 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "Order-based formals may not appear among named formals." ) ) );
707 $$->seenDefault_ = true;
708 typedef typeof $$->exprs_ ListType;
709 size_t ** pos = new size_t * ( 0 );
710 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @2, $$->exprs_.size( ), $4 );
711 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
714 | OneOrMoreSplitFormals Identifier ':' '.' Identifier
717 $$->seenNamed_ = true;
718 typedef typeof $$->exprs_ ListType;
719 size_t ** pos = new size_t * ( 0 );
720 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, $5, 0 );
721 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
724 | OneOrMoreSplitFormals Identifier ':' '.' Identifier ':' Expr
727 $$->seenNamed_ = true;
728 typedef typeof $$->exprs_ ListType;
729 size_t ** pos = new size_t * ( 0 );
730 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, $5, $7 );
731 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
734 | OneOrMoreSplitFormals Identifier ':' '.' '\"'
737 $$->seenNamed_ = true;
738 typedef typeof $$->exprs_ ListType;
739 size_t ** pos = new size_t * ( 0 );
740 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, strdup( $2 ), 0 );
741 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
744 | OneOrMoreSplitFormals Identifier ':' '.' '\"' ':' Expr
747 $$->seenNamed_ = true;
748 typedef typeof $$->exprs_ ListType;
749 size_t ** pos = new size_t * ( 0 );
750 Ast::StructSplitReference * ref = new Ast::StructSplitReference( @5, strdup( $2 ), $7 );
751 $$->exprs_.push_back( ListType::value_type( new Ast::DefineVariable( @2, $2, ref, pos ),
758 : '\\' Formals T_mapsto FunctionModeList Expr
760 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
761 Ast::FunctionFunction * res = new Ast::FunctionFunction( @$, $2, $5, $4 );
762 res->push_exprs( args );
763 $$ = new Ast::CallExpr( @$,
764 RefCountPtr< const Lang::Function >( res ),
767 | '(' OperatorFunction ')'
776 $$ = new list< RefCountPtr< const char > >( );
778 | OneOrMoreOrderedFormals
781 OneOrMoreOrderedFormals
784 $$ = new list< RefCountPtr< const char > >( );
785 $$->push_back( strrefdup( $1 ) );
787 | OneOrMoreOrderedFormals Identifier
790 $$->push_back( strrefdup( $2 ) );
797 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_MINUSMINUS ) );
801 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_PLUSPLUS ) );
805 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_AMPERSAND ) );
809 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_PLUS ) );
813 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_MINUS ) );
817 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_STAR ) );
821 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_SLASH ) );
825 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_PROJECTION ) );
829 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_ANGLE ) );
833 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_AMPERSAND_MORE ) );
837 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_NEG ) );
841 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_COMPOSE ) );
845 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_LESS ) );
849 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_GREATER ) );
853 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_EQEQ ) );
857 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_EQNEQ ) );
861 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_LESSEQ ) );
865 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_GREATEREQ ) );
869 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_NOT ) );
873 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_FUNCTION_AND ) );
877 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_FUNCTION_OR ) );
881 $$ = new Ast::Constant( @$, static_cast< RefCountPtr< const Lang::Value > >( Lang::THE_OPERATOR_XOR ) );
886 : ExprExceptConstStrings
889 $$ = new Ast::Constant( @1, $1 );
893 ExprExceptConstStrings
894 : ConstantExceptStrings
897 | '(' T_identifier_tex ExprExceptConstStrings ')'
899 Interaction::warn_or_push( new Exceptions::ParserError( @2, strrefdup( "The special form TeX is deprecated. \"TeX\" is now an ordinary variable, and shall be called like a function, [TeX <expr>]." ), true ),
900 & Ast::theAnalysisErrorsList );
901 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
902 args->orderedExprs_->push_back( $3 );
903 $$ = new Ast::CallExpr( @$,
904 Ast::THE_FUNCTION_TeX,
907 | '(' T_identifier_tex T_string ')'
909 Interaction::warn_or_push( new Exceptions::ParserError( @2, strrefdup( "The special form TeX is deprecated. \"TeX\" is now an ordinary variable, and shall be called like a function, [TeX <expr>]." ), true ),
910 & Ast::theAnalysisErrorsList );
911 Kernel::theTeXLabelManager.announce( std::string( $3->val_.getPtr( ) ), @3 );
912 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
913 args->orderedExprs_->push_back( new Ast::Constant( @3, $3 ) );
914 $$ = new Ast::CallExpr( @$,
915 Ast::THE_FUNCTION_TeX,
921 $$->immediate_ = true;
926 | SuperMemberReference
934 $$ = new Ast::NegExpr( @$, @2, $3 );
938 $$ = new Ast::RelativeExpr( @$, @2, $3 );
942 $$ = new Ast::EmptyExpression( @$ );
944 | '(' Expr T_llthan InsertionSequence ')'
946 std::list< Ast::Node * > * bracket = new std::list< Ast::Node * >( );
948 size_t ** pos = new size_t * ( 0 );
949 Ast::StateReference * dst = new Ast::LexiographicState( @2, strdup( Kernel::SEQUENTIAL_EXPR_VAR_ID ), new Kernel::Environment::LexicalKey * ( 0 ) );
951 bracket->push_back( new Ast::IntroduceState( @3,
952 strdup( Kernel::SEQUENTIAL_EXPR_VAR_ID ),
955 for( std::list< Ast::Expression * >::iterator i = $4->begin( ); i != $4->end( ); ++i )
957 Ast::InsertionMutatorCall * mutExpr = dynamic_cast< Ast::InsertionMutatorCall * >( *i );
960 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
961 args->orderedStates_->push_back( dst );
962 Ast::CallExpr * call =
963 new Ast::CallExpr( mutExpr->loc( ),
968 bracket->push_back( call );
972 bracket->push_back( new Ast::Insertion( dst, *i ) );
975 bracket->push_back( new Ast::Freeze( @3, strdup( Kernel::SEQUENTIAL_EXPR_VAR_ID ), pos ) );
976 $$ = new Ast::CodeBracket( @$, bracket );
980 $$ = new Ast::EvalOutsideExpr( @$, $2 );
987 Kernel::Environment::LexicalKey ** key = new Kernel::Environment::LexicalKey * ( 0 );
988 $$ = new Ast::LexiographicVariable( @$, $1, key );
992 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
993 Ast::EvalSymbolFunction * res = new Ast::EvalSymbolFunction( @$, $2 );
994 res->push_exprs( args );
995 $$ = new Ast::CallExpr( @$,
996 RefCountPtr< const Lang::Function >( res ),
999 | T_dynamic_identifier
1001 $$ = new Ast::DynamicVariable( @$, $1 );
1003 | '(' StateReference ')'
1005 $$ = new Ast::Peek( @$, $2 );
1008 | Expr '.' Identifier
1010 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1011 Ast::MemberReferenceFunction * res = new Ast::MemberReferenceFunction( @$, $1, $3 );
1012 res->push_exprs( args );
1013 $$ = new Ast::CallExpr( @$,
1014 RefCountPtr< const Lang::Function >( res ),
1018 | '(' T_esc_continuation Identifier Expr ')'
1020 $$ = new Ast::LetDynamicECExpr( @$, @3, $3, $4 );
1022 | '(' T_esc_continue Identifier Expr ')'
1024 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1025 Ast::ContinueDynamicECFunction * res = new Ast::ContinueDynamicECFunction( @3, $3, $4 );
1026 res->push_exprs( args );
1027 $$ = new Ast::CallExpr( @$,
1028 RefCountPtr< const Lang::Function >( res ),
1030 /* This used to be immediate, but right now that seems utterly wrong!
1031 * Imagine choosing between two continuations; then both continuations would require invokation before being "passed" to the <if> function.
1032 * 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
1033 * knowing when they will be forced... But I don't think there's a choice here anyway; this expression can't be immediate.
1036 | '(' T_esc_backtrace Identifier ')'
1038 $$ = new Ast::GetECBacktraceExpr( @3, $3 );
1040 | '(' T_indexof Identifier ')'
1042 $$ = new Ast::LexicalVariableLocationExpr( @3, $3, Ast::LexicalVariableLocationExpr::INDEX );
1044 | '(' T_depthof Identifier ')'
1046 $$ = new Ast::LexicalVariableLocationExpr( @3, $3, Ast::LexicalVariableLocationExpr::DEPTH );
1050 $$ = new Ast::LexicalVariableNameExpr( @1 );
1052 | T_absLeft Expr T_absRight
1054 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1055 args->orderedExprs_->push_back( $2 );
1056 $$ = new Ast::CallExpr( @$,
1057 Lang::THE_FUNCTION_ABS,
1062 $$ = new Ast::WithDynamicExpr( @$, $1, $3 );
1064 | T_unionLeft ArgList T_unionRight
1066 $$ = new Ast::UnionExpr( @$, $2 );
1068 | Expr T_minusminus T_cycle
1070 $$ = new Ast::CycleExpr( @3, $1 );
1072 | Expr T_minusminus Expr
1074 $$ = new Ast::MinusMinusExpr( @2, $1, $3 );
1076 | Expr T_plusplus Expr
1078 $$ = new Ast::PlusPlusExpr( @2, $1, $3 );
1082 $$ = new Ast::AmpersandExpr( @2, $1, $3 );
1086 $$ = new Ast::PlusExpr( @2, $1, $3 );
1090 $$ = new Ast::MinusExpr( @2, $1, $3 );
1094 $$ = new Ast::AngleExpr( @2, $1, $3 );
1096 | Expr T_ampersandMore Expr
1098 $$ = new Ast::AmpersandMoreExpr( @2, $1, $3 );
1102 $$ = new Ast::StarExpr( @2, $1, $3 );
1104 | Expr T_projection Expr
1106 $$ = new Ast::ProjectionExpr( @2, $1, $3 );
1110 $$ = new Ast::SlashExpr( @2, $1, $3 );
1114 $$ = new Ast::NegExpr( @1, $2 );
1116 | Expr T_compose Expr
1118 $$ = new Ast::ComposeExpr( @2, $1, $3 );
1122 $$ = new Ast::LessExpr( @2, $1, $3 );
1126 $$ = new Ast::GreaterExpr( @2, $1, $3 );
1130 $$ = new Ast::EqualExpr( @2, $1, $3 );
1134 $$ = new Ast::NotEqualExpr( @2, $1, $3 );
1136 | Expr T_lesseq Expr
1138 $$ = new Ast::LessEqualExpr( @2, $1, $3 );
1140 | Expr T_greatereq Expr
1142 $$ = new Ast::GreaterEqualExpr( @2, $1, $3 );
1146 $$ = new Ast::NotExpr( @1, $2 );
1150 // $$ = new Ast::AndExpr( @2, $1, $3 );
1152 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1153 args->orderedExprs_->push_back( $1 );
1154 args->orderedExprs_->push_back( $3 );
1155 $$ = new Ast::CallExpr( @$,
1156 Lang::THE_FUNCTION_AND,
1161 // $$ = new Ast::OrExpr( @2, $1, $3 );
1163 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1164 args->orderedExprs_->push_back( $1 );
1165 args->orderedExprs_->push_back( $3 );
1166 $$ = new Ast::CallExpr( @$,
1167 Lang::THE_FUNCTION_OR,
1172 $$ = new Ast::XorExpr( @2, $1, $3 );
1176 Kernel::Environment::LexicalKey ** key = new Kernel::Environment::LexicalKey * ( 0 );
1177 $$ = new Ast::LexiographicType( @$, $1, key );
1181 $$ = new Ast::SpanLastExpr( @$ );
1187 : T_dynamic_identifier ':' Expr %prec T_dynamiccolon
1189 $$ = new Ast::DynamicBindingExpression( @1, $1, $3, new Kernel::Environment::LexicalKey * ( 0 ) );
1191 | T_dynamic_identifier ':' T_dynamic Expr %prec T_dynamiccolon
1193 $$ = new Ast::DynamicBindingExpression( @1, $1,
1194 new Ast::DynamicExpression( @4, $4 ),
1195 new Kernel::Environment::LexicalKey * ( 0 ) );
1197 | T_dynamic_state_identifier ':' StateReference %prec T_dynamiccolon
1199 $$ = new Ast::DynamicStateBindingExpression( @1, @1, $1, $3 );
1204 ConstantExceptStrings
1207 $$ = new Ast::Constant( @1, new Lang::Float( $1 ) );
1211 $$ = new Ast::Constant( @1, new Lang::Length( $1 ) );
1215 $$ = new Ast::Constant( @1, new Lang::Integer( $1 ) );
1219 $$ = new Ast::Constant( @1, new Lang::Boolean( $1 ) );
1223 $$ = new Ast::Constant( @1, new Lang::Symbol( $1 ) );
1227 $$ = new Ast::Constant( @1, new Lang::Character( $1 ) );
1234 $$ = new Ast::CodeBracket( @$, $2 );
1241 $$ = $1; // Explicit upcast avoids bison warning.
1243 | Identifier ':' Expr
1245 size_t ** pos = new size_t * ( 0 );
1246 $$ = new Ast::DefineVariable( @1, $1, $3, pos );
1248 | T_state_identifier ':' Expr
1250 size_t ** pos = new size_t * ( 0 );
1251 $$ = new Ast::IntroduceState( @1, $1, $3, pos );
1253 | T_state_identifier ';'
1255 size_t ** pos = new size_t * ( 0 );
1256 $$ = new Ast::Freeze( @1, $1, pos );
1258 | Identifier ':' T_state_identifier ';'
1260 size_t ** posVar = new size_t * ( 0 );
1261 size_t ** posState = new size_t * ( 0 );
1262 $$ = new Ast::DefineVariable( @1, $1, new Ast::Freeze( @3, $3, posState ), posVar );
1264 | T_dynamic T_dynamic_identifier Expr Expr
1266 $$ = new Ast::DynamicVariableDecl( @$, @2, $2, $3, $4 );
1268 | T_dynamic T_dynamic_identifier Expr T_dynamic Expr
1270 $$ = new Ast::DynamicVariableDecl( @$, @2, $2, $3,
1271 new Ast::DynamicExpression( @5, $5 ) );
1273 | T_dynamic T_dynamic_state_identifier StateReference
1275 $$ = new Ast::DynamicStateDecl( @$, @2, $2, $3, new size_t * ( 0 ) );
1279 $$ = new Ast::SourceLocationMark( @$ );
1286 $$ = new std::list< Ast::Expression * >( );
1287 $$->push_back( $1 );
1291 $$ = new std::list< Ast::Expression * >( );
1292 $$->push_back( new Ast::InsertionMutatorCall( @$, $2 ) );
1294 | T_ggthan MutatorCallbackExpr
1296 $$ = new std::list< Ast::Expression * >( );
1297 $$->push_back( new Ast::InsertionMutatorCall( @$, $2 ) );
1299 | InsertionSequence T_llthan Expr
1302 $$->push_back( $3 );
1304 | InsertionSequence T_llthan T_ggthan Expr
1307 $$->push_back( new Ast::InsertionMutatorCall( Ast::SourceLocation( @3, @4 ), $4 ) );
1309 | InsertionSequence T_llthan T_ggthan MutatorCallbackExpr
1312 $$->push_back( new Ast::InsertionMutatorCall( Ast::SourceLocation( @3, @4 ), $4 ) );
1319 $$ = new list< Ast::Node * >( );
1320 $$->push_back( $1 );
1322 | OneOrMoreGroupElems GroupElem
1325 $$->push_back( $2 );
1327 | StateReference T_llthan InsertionSequence
1329 $$ = new list< Ast::Node * >( );
1330 for( std::list< Ast::Expression * >::iterator i = $3->begin( ); i != $3->end( ); ++i )
1332 Ast::InsertionMutatorCall * mutExpr = dynamic_cast< Ast::InsertionMutatorCall * >( *i );
1335 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1336 args->orderedStates_->push_back( $1 );
1337 Ast::CallExpr * call =
1338 new Ast::CallExpr( mutExpr->loc( ),
1339 mutExpr->getExpr( ),
1343 $$->push_back( call );
1347 $$->push_back( new Ast::Insertion( $1, *i ) );
1351 | OneOrMoreGroupElems StateReference T_llthan InsertionSequence
1354 for( std::list< Ast::Expression * >::iterator i = $4->begin( ); i != $4->end( ); ++i )
1356 Ast::InsertionMutatorCall * mutExpr = dynamic_cast< Ast::InsertionMutatorCall * >( *i );
1359 Ast::ArgListExprs * args = new Ast::ArgListExprs( true );
1360 args->orderedStates_->push_back( $2 );
1361 Ast::CallExpr * call =
1362 new Ast::CallExpr( mutExpr->loc( ),
1363 mutExpr->getExpr( ),
1367 $$->push_back( call );
1371 $$->push_back( new Ast::Insertion( $2, *i ) );
1375 | T_splitLeft SplitFormals T_splitRight ':' Expr
1377 $$ = new list< Ast::Node * >( );
1378 size_t ** pos = new size_t * ( 0 );
1380 $5->immediate_ = true;
1381 $$->push_back( new Ast::DefineVariable( @5, $2->newSplitVarId( ), $5, pos ) );
1383 size_t orderedCount = 0;
1385 typedef typeof $2->exprs_ ListType;
1386 for( ListType::iterator i = $2->exprs_.begin( ); i != $2->exprs_.end( ); ++i )
1388 i->second->setStruct( @5, pos );
1389 $$->push_back( i->first );
1390 if( i->second->isOrdered( ) )
1396 if( $2->sinkDefine_ != 0 )
1398 $2->sinkExpr_->setStruct( @5, pos, orderedCount );
1399 $$->push_back( $2->sinkDefine_ );
1403 $$->push_back( new Ast::AssertNoSinkNeeded( @2, orderedCount, @5, pos ) );
1406 | T_splitLeft SplitFormals T_splitRight Expr
1408 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @4, strrefdup( "Expected ':'." ) ) );
1409 $$ = new list< Ast::Node * >( );
1410 $$->push_back( new Ast::ErrorExpression( @$ ) );
1412 | OneOrMoreGroupElems T_splitLeft SplitFormals T_splitRight ':' Expr
1415 size_t ** pos = new size_t * ( 0 );
1417 $6->immediate_ = true;
1418 $$->push_back( new Ast::DefineVariable( @6, $3->newSplitVarId( ), $6, pos ) );
1420 size_t orderedCount = 0;
1422 typedef typeof $3->exprs_ ListType;
1423 for( ListType::iterator i = $3->exprs_.begin( ); i != $3->exprs_.end( ); ++i )
1425 i->second->setStruct( @6, pos );
1426 $$->push_back( i->first );
1427 if( i->second->isOrdered( ) )
1433 if( $3->sinkDefine_ != 0 )
1435 $3->sinkExpr_->setStruct( @6, pos, orderedCount );
1436 $$->push_back( $3->sinkDefine_ );
1440 $$->push_back( new Ast::AssertNoSinkNeeded( @3, orderedCount, @6, pos ) );
1443 | OneOrMoreGroupElems T_splitLeft SplitFormals T_splitRight Expr
1445 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @4, strrefdup( "Expected ':'." ) ) );
1447 $$->push_back( new Ast::ErrorExpression( @$ ) );
1454 $$ = new list< Ast::Node * >( );
1456 | OneOrMoreGroupElems
1460 SuperMemberReference
1461 : '(' '#' Expr ')' '.' Identifier
1463 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1464 Ast::ProtectedMemberReferenceFunction * res = new Ast::ProtectedMemberReferenceFunction( @$, @2, $3, @6, $6 );
1465 res->push_exprs( args );
1466 $$ = new Ast::CallExpr( @$,
1467 RefCountPtr< const Lang::Function >( res ),
1474 : Identifier '#' Identifier
1476 Kernel::Environment::LexicalKey ** key = new Kernel::Environment::LexicalKey * ( 0 );
1477 $$ = new Ast::MethodIdExpr( @$, new Ast::LexiographicVariable( @1, $1, key ), $3 );
1483 : '[' '(' '#' Expr ')' '.' MethodIdentifier ArgList ']'
1485 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1486 Ast::ProtectedMethodReferenceFunction * res = new Ast::ProtectedMethodReferenceFunction( @$, @3, $4, $7 );
1487 res->push_exprs( args );
1488 $$ = new Ast::CallExpr( @$,
1489 new Ast::CallExpr( @3,
1490 RefCountPtr< const Lang::Function >( res ),
1494 | '[' '(' '#' ')' '.' MethodIdentifier ArgList ']'
1496 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1497 Ast::ProtectedMethodReferenceFunction * res = new Ast::ProtectedMethodReferenceFunction( @$, @3, 0, $6 );
1498 res->push_exprs( args );
1499 $$ = new Ast::CallExpr( @$,
1500 new Ast::CallExpr( @3,
1501 RefCountPtr< const Lang::Function >( res ),
1509 : '[' T_class '(' Expr Formals ')' Identifier '(' ListOfParentsWithInitargs ')'
1514 DeleteOnExit< char > isaDeleter( $7 );
1515 if( strcmp( $7, "isa" ) != 0 )
1517 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @7, strrefdup( "Expected \"isa\"." ) ) );
1519 if( ( $11 & Ast::CLASS_MODE_ABSTRACT ) != 0 && ( $11 & Ast::CLASS_MODE_FINAL ) != 0 )
1521 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @11, strrefdup( "Declaring a class both abstract and final is forbidden." ) ) );
1524 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1525 Ast::ClassFunction * res = new Ast::ClassFunction( @$, $4, $5, $9, $11, $12 );
1526 res->push_exprs( args );
1527 $$ = new Ast::CallExpr( @$,
1528 RefCountPtr< const Lang::Function >( res ),
1533 ListOfParentsWithInitargs
1534 : '(' Expr ArgList ')'
1536 $$ = new std::list< const Ast::CallExpr * >;
1537 $$->push_back( new Ast::CallExpr( @$, $2, $3 ) );
1539 | ListOfParentsWithInitargs '(' Expr ArgList ')'
1542 $$->push_back( new Ast::CallExpr( Ast::SourceLocation( @2, @5 ), $3, $4 ) );
1551 | OneOrMoreClassModeSpecifiers
1554 OneOrMoreClassModeSpecifiers
1555 : ClassModeSpecifier
1556 | OneOrMoreClassModeSpecifiers ClassModeSpecifier
1565 DeleteOnExit< char > strDeleter( $1 );
1567 if( strcmp( $1, "abstract" ) == 0 )
1569 $$ = Ast::CLASS_MODE_ABSTRACT;
1571 else if( strcmp( $1, "final" ) == 0 )
1573 $$ = Ast::CLASS_MODE_FINAL;
1577 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @$, strrefdup( "This is not a valid class mode specifier" ) ) );
1585 $$ = new std::list< Ast::ClassSection * >;
1587 | OneOrMoreClassSections
1590 OneOrMoreClassSections
1593 $$ = new std::list< Ast::ClassSection * >;
1594 $$->push_back( $1 );
1596 | OneOrMoreClassSections ClassSection
1599 $$->push_back( $2 );
1604 : '(' T_members MemberDeclarations ')'
1608 | '(' T_prepare Group ')'
1610 $$ = new Ast::PrepareSection( @$, $3 );
1612 | '(' Identifier MethodDeclarations ')'
1614 DeleteOnExit< char > accessSpecDeleter( $2 );
1615 unsigned int accessSpec = 0;
1616 if( strcmp( $2, "__methods__" ) == 0 )
1618 accessSpec = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET;
1620 else if( strcmp( $2, "__abstract__" ) == 0 )
1622 accessSpec = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_ABSTRACT;
1624 else if( strcmp( $2, "__final__" ) == 0 )
1626 accessSpec = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_FINAL;
1628 else if( strcmp( $2, "__protected__" ) == 0 )
1630 accessSpec = Ast::MEMBER_ACCESS_PROTECTED_GET;
1632 else if( strcmp( $2, "__private__" ) == 0 )
1638 Ast::theAnalysisErrorsList.push_back( new Exceptions::ParserError( @2, strrefdup( "This is not a valid method access specifier." ) ) );
1640 $3->addModeBits( accessSpec );
1643 | '(' T_abstract OrderedFormals ')'
1645 $$ = new Ast::AbstractSection( @$, $3 );
1647 | '(' T_overrides Expr T_gr__ MethodDeclarations ')'
1649 $$ = new Ast::OverridesSection( $3, $5 );
1656 $$ = new Ast::MemberSection;
1658 | OneOrMoreMemberDeclarations
1661 OneOrMoreMemberDeclarations
1664 $$ = new Ast::MemberSection;
1665 $$->push_back( $1 );
1667 | OneOrMoreMemberDeclarations MemberDeclaration
1670 $$->push_back( $2 );
1675 : '(' Identifier Expr ')'
1677 $$ = new Ast::MemberDeclaration( @$, $2, $3, 0 );
1679 | '(' Identifier Expr MemberAccessList ')'
1681 $$ = new Ast::MemberDeclaration( @$, $2, $3, $4 );
1686 : MemberAccessSpecifier
1687 | MemberAccessList MemberAccessSpecifier
1693 MemberAccessSpecifier
1696 $$ = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PROTECTED_GET;
1700 $$ = Ast::MEMBER_ACCESS_PUBLIC_GET | Ast::MEMBER_ACCESS_PUBLIC_INSERT | Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_ACCESS_PROTECTED_INSERT;
1704 $$ = Ast::MEMBER_ACCESS_PROTECTED_GET;
1706 | '(' '#' T_llthan ')'
1708 $$ = Ast::MEMBER_ACCESS_PROTECTED_GET | Ast::MEMBER_ACCESS_PROTECTED_INSERT;
1712 $$ = Ast::MEMBER_TRANSFORMING;
1719 $$ = new Ast::MemberSection;
1721 | OneOrMoreMethodDeclarations
1724 OneOrMoreMethodDeclarations
1727 $$ = new Ast::MemberSection;
1728 $$->push_back( $1 );
1730 | OneOrMoreMethodDeclarations MethodDeclaration
1733 $$->push_back( $2 );
1738 : '(' Identifier Expr ')'
1740 $$ = new Ast::MemberDeclaration( @$, $2, $3, Ast::MEMBER_CONST | Ast::MEMBER_METHOD );
1742 | '(' '[' Identifier Formals ']' FunctionModeList GroupElem ')'
1744 Ast::Expression * body = dynamic_cast< Ast::Expression * >( $7 );
1747 std::list< Ast::Node * > * bracket = new std::list< Ast::Node * >( );
1748 bracket->push_back( $7 );
1749 body = new Ast::CodeBracket( @7, bracket );
1751 Ast::ArgListExprs * args = new Ast::ArgListExprs( false );
1752 Ast::FunctionFunction * res = new Ast::FunctionFunction( @$, $4, body, $6 );
1753 res->push_exprs( args );
1754 $$ = new Ast::MemberDeclaration( @$, $3, new Ast::CallExpr( @$,
1755 RefCountPtr< const Lang::Function >( res ),
1757 Ast::MEMBER_CONST | Ast::MEMBER_METHOD | ( (($6 & Ast::FUNCTION_TRANSFORMING) != 0) ? Ast::MEMBER_TRANSFORMING : 0 ) );
1766 | OneOrMoreFunctionModeSpecifiers
1769 OneOrMoreFunctionModeSpecifiers
1770 : FunctionModeSpecifier
1771 | OneOrMoreFunctionModeSpecifiers FunctionModeSpecifier
1777 FunctionModeSpecifier
1780 $$ = Ast::FUNCTION_TRANSFORMING;
1793 | T_identifier_except_tex
1798 /* The closing %% above marks the end of the Rules section and the beginning
1799 * of the User Subroutines section. All text from here to the end of the
1800 * file is copied verbatim to the end of the generated y.tab.c file.
1801 * This section is where you put definitions of helper functions.