1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "parser-util.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_PRINTER_USED
8 #define PROP_REGEXP_MATCHING_USED
9 #define PROP_PARSER_USED
10 #define PROP_QUARK_USED
12 ///////////////////////////////////////////////////////////////////////////////
14 ///////////////////////////////////////////////////////////////////////////////
15 static const Quark
_p_a_r_s_e_rcn_u_t_i_lco_c_c_Q1("$$");
16 static const Quark
_p_a_r_s_e_rcn_u_t_i_lco_c_c_Q2("$");
17 #line 1 "parser-util.pcc"
18 ///////////////////////////////////////////////////////////////////////////////
20 // This file implements the utility routines for the parser.
22 ///////////////////////////////////////////////////////////////////////////////
25 #include <AD/pretty/postream.h>
40 ///////////////////////////////////////////////////////////////////////////////
42 // Explaination mechanism for parser error.
44 ///////////////////////////////////////////////////////////////////////////////
45 #line 28 "parser-util.pcc"
46 #line 28 "parser-util.pcc"
47 ///////////////////////////////////////////////////////////////////////////////
49 // Interface specification of datatype PropToken
51 ///////////////////////////////////////////////////////////////////////////////
52 #line 28 "parser-util.pcc"
53 ///////////////////////////////////////////////////////////////////////////////
55 // Pretty printing methods for PropToken
57 ///////////////////////////////////////////////////////////////////////////////
58 std::ostream
& operator << (std::ostream
& strm__
, PropToken obj__
);
59 PrettyOStream
& operator << (PrettyOStream
& strm__
, PropToken obj__
);
61 ///////////////////////////////////////////////////////////////////////////////
63 // Instantiation of datatype PropToken
65 ///////////////////////////////////////////////////////////////////////////////
66 #line 28 "parser-util.pcc"
67 ///////////////////////////////////////////////////////////////////////////////
69 // Pretty printing methods for PropToken
71 ///////////////////////////////////////////////////////////////////////////////
72 std::ostream
& operator << (std::ostream
& strm__
, PropToken obj__
)
73 { PrettyOStream
S(strm__
); S
<< obj__
; return strm__
; }
75 PrettyOStream
& operator << (PrettyOStream
& strm__
, PropToken obj__
)
79 case XX_r_e_w_r_i_t_eXX
:
82 case XX_i_n_f_e_r_e_n_c_eXX
:
83 strm__
<< "inference";
88 case XX_m_a_t_c_h_a_l_lXX
:
91 case XX_m_a_t_c_h_s_c_a_nXX
:
92 strm__
<< "matchscan";
94 case XX_r_e_f_i_n_eXX
:
97 case XX_c_l_a_s_s_o_fXX
:
103 case XX_d_a_t_a_t_y_p_eXX
:
104 strm__
<< "datatype";
106 case XX_i_n_s_t_a_n_t_i_a_t_eXX
:
107 strm__
<< "instantiate";
109 case XX_l_e_x_e_m_eXX
:
112 case XX_b_i_t_f_i_e_l_dXX
:
113 strm__
<< "bitfield";
118 case XX_s_y_n_t_a_xXX
:
121 case XX_d_a_t_a_f_l_o_wXX
:
122 strm__
<< "dataflow";
124 case XX_m_o_d_u_l_eXX
:
127 case XX_s_i_g_n_a_t_u_r_eXX
:
128 strm__
<< "signature";
130 case XX_c_o_n_s_t_r_a_i_n_tXX
:
131 strm__
<< "constraint";
133 case XX_d_e_c_l_a_r_eXX
:
136 case XX_p_r_o_c_e_d_u_r_eXX
:
137 strm__
<< "procedure";
142 case XX_f_u_n_c_t_i_o_nXX
:
143 strm__
<< "function";
145 case XX_g_r_a_p_h_t_y_p_eXX
:
146 strm__
<< "graphtype";
148 case XX_g_r_a_p_h_r_e_w_r_i_t_eXX
:
149 strm__
<< "graphrewrite";
151 case XX_c_u_t_r_e_w_r_i_t_eXX
:
152 strm__
<< "cutrewrite";
154 case XX_f_a_i_l_r_e_w_r_i_t_eXX
:
155 strm__
<< "failrewrite";
157 case XX_a_t_t_r_i_b_u_t_e_g_r_a_m_m_a_rXX
:
158 strm__
<< "attributegrammar";
184 case XX_u_n_i_f_i_a_b_l_eXX
:
185 strm__
<< "unifiable";
196 case XX_c_o_n_t_i_n_u_eXX
:
197 strm__
<< "continue";
208 case XX_p_u_b_l_i_cXX
:
211 case XX_p_r_o_t_e_c_t_e_dXX
:
212 strm__
<< "protected";
214 case XX_p_r_i_v_a_t_eXX
:
220 case XX_e_x_t_e_r_nXX
:
223 case XX_m_u_t_a_b_l_eXX
:
226 case XX_a_p_p_l_i_c_a_t_i_v_eXX
:
227 strm__
<< "applicative";
229 case XX_v_i_r_t_u_a_lXX
:
238 case XX_c_o_l_l_e_c_t_a_b_l_eXX
:
239 strm__
<< "collectable";
241 case XX_f_i_n_a_l_i_z_a_b_l_eXX
:
242 strm__
<< "finalizable";
244 case XX_p_r_i_n_t_a_b_l_eXX
:
245 strm__
<< "printable";
247 case XX_t_r_a_c_e_dXX
:
250 case XX_p_e_r_s_i_s_t_e_n_tXX
:
251 strm__
<< "persistent";
253 case XX_t_r_e_e_p_a_r_s_e_rXX
:
254 strm__
<< "treeparser";
256 case XX_i_n_l_i_n_eXX
:
262 case XX_s_w_i_t_c_hXX
:
265 case XX_u_n_s_i_g_n_e_dXX
:
266 strm__
<< "unsigned";
268 case XX_s_i_g_n_e_dXX
:
274 case XX_c_a_t_e_g_o_r_yXX
:
275 strm__
<< "category";
277 case XX_f_u_n_c_t_o_rXX
:
280 case XX_f_e_a_t_u_r_eXX
:
283 case XX_s_h_a_r_i_n_gXX
:
286 case XX_r_e_l_a_t_i_o_nXX
:
287 strm__
<< "relation";
292 case XX_i_n_h_e_r_i_t_e_dXX
:
293 strm__
<< "inherited";
295 case XX_r_e_t_u_r_nXX
:
298 case XX_s_y_n_t_h_e_s_i_z_e_dXX
:
299 strm__
<< "synthesized";
307 case XX_r_i_g_h_tdkXX
:
310 case XX_e_x_p_e_c_tdkXX
:
325 case XX_m_u_l_t_i_m_a_p_o_fXX
:
326 strm__
<< "multimapof";
328 case XX_l_i_s_t_o_fXX
:
331 case XX_p_r_i_q_u_e_u_e_o_fXX
:
332 strm__
<< "priqueueof";
334 case XX_q_u_e_u_e_o_fXX
:
337 case XX_d_e_q_u_e_o_fXX
:
340 case XX_t_u_p_l_e_o_fXX
:
343 case XX_f_o_r_a_l_lXX
:
346 case XX_e_x_i_s_t_sXX
:
361 case XX_i_n_c_l_u_d_eXX
:
373 case XX_i_m_p_l_i_e_sdkXX
:
374 strm__
<< "implies:";
379 case XX_e_q_u_i_vdkXX
:
385 case XX_s_p_a_c_edkXX
:
388 case XX_n_o_d_e_sdkXX
:
391 case XX_e_d_g_e_sdkXX
:
394 case XX_i_n_d_e_xdkXX
:
400 case XX_e_q_u_a_l_i_t_ydkXX
:
401 strm__
<< "equality:";
403 case XX_p_r_e_o_r_d_e_rdkXX
:
404 strm__
<< "preorder:";
406 case XX_p_o_s_t_o_r_d_e_rdkXX
:
407 strm__
<< "postorder:";
409 case XX_b_e_f_o_r_edkXX
:
412 case XX_t_o_p_d_o_w_ndkXX
:
413 strm__
<< "topdown:";
415 case XX_b_o_t_t_o_m_u_pdkXX
:
416 strm__
<< "bottomup:";
418 case XX_s_t_r_a_t_e_g_ydkXX
:
419 strm__
<< "strategy:";
421 case XX_o_r_d_e_rdkXX
:
424 case XX_p_r_a_g_m_adkXX
:
527 strm__
<< "LONG_BAR";
530 strm__
<< "CONS_TOK";
533 strm__
<< "DOMAIN_TOK";
536 strm__
<< "CONS_EXP";
539 strm__
<< "META_QUOTE";
542 strm__
<< "POLY_DATATYPE";
545 strm__
<< "ATTRIB_ID";
581 strm__
<< "REAL_TOK";
584 strm__
<< "CHAR_TOK";
587 strm__
<< "STRING_TOK";
593 strm__
<< "REGEXP_TOK";
596 strm__
<< "QUARK_TOK";
599 strm__
<< "BIGINT_TOK";
602 strm__
<< "PUNCTUATIONS";
610 #line 28 "parser-util.pcc"
611 #line 28 "parser-util.pcc"
614 void PropParser::print_user_symbol(std::ostream
& f
, Symbol c
)
615 { f
<< '"' << (PropToken
)c
<< '"'; }
617 void PropParser::explain_error()
618 { nice_explain(std::cerr
); std::cerr
<< '\n';
619 if (options
.debug
) debug_explain(std::cerr
);
622 extern int match_rule
;
623 ///////////////////////////////////////////////////////////////////////////////
627 ///////////////////////////////////////////////////////////////////////////////
628 PropParser::~PropParser() {}
630 ///////////////////////////////////////////////////////////////////////////////
632 // Method to initialize the parser
634 ///////////////////////////////////////////////////////////////////////////////
635 void PropParser::initialize(Compiler
& C
)
641 options
.emit_code
= true;
644 antecedent_count
= 0;
655 #line 70 "parser-util.pcc"
656 #line 70 "parser-util.pcc"
658 #line 70 "parser-util.pcc"
659 #line 70 "parser-util.pcc"
668 ///////////////////////////////////////////////////////////////////////////////
669 // Method to push/pop the rw stack
670 ///////////////////////////////////////////////////////////////////////////////
671 void PropParser::push_rw_stack()
673 if (rw_top
>= MAX_LEXICAL_DEPTH
) bug("rw stack overflow");
674 rw_stack
[rw_top
].mode
= MatchRuleInfo::BOTTOMUP
;
675 rw_stack
[rw_top
].option
= MatchRuleInfo::NO_OPTIONS
;
676 rw_stack
[rw_top
].qual
= QUALnone
;
679 void PropParser::pop_rw_stack()
681 if (rw_top
< 0) bug("rw stack underflow");
684 ///////////////////////////////////////////////////////////////////////////////
685 // Functions to mark a tree with the current location.
686 ///////////////////////////////////////////////////////////////////////////////
687 Pat
mark(Pat p
) { p
= MARKEDpat(Loc(),p
); return p
; }
688 Exp
mark(Exp e
) { e
= MARKEDexp(Loc(),e
); return e
; }
689 Decl
mark(Decl d
) { if (d
!= NOdecl
) d
= MARKEDdecl(Loc(),d
); return d
; }
691 ///////////////////////////////////////////////////////////////////////////////
693 // Function to mark tuples used
695 ///////////////////////////////////////////////////////////////////////////////
696 void mark_tuple_used (int arity
)
697 { if (arity
<= 1 || arity
> MAX_TUPLE_ARITY
)
698 { bug("Illegal tuple arity: %i", arity
); }
699 Used::tuple
[arity
] = true;
702 ///////////////////////////////////////////////////////////////////////////////
703 // Functions to build lists.
704 ///////////////////////////////////////////////////////////////////////////////
705 Pat
mklistpat(Id cons
, Id nil
, Pats ps
, Pat p
= NOpat
)
707 #line 116 "parser-util.pcc"
708 #line 116 "parser-util.pcc"
709 LISTpat(lookup_cons(cons
), lookup_cons(nil
), ps
, p
)
710 #line 120 "parser-util.pcc"
711 #line 120 "parser-util.pcc"
715 (Id a
, Pat len
, Pat array
, Pats ps
, Bool flex1
= false, Bool flex2
= false)
716 { Used::vector
= true;
718 #line 125 "parser-util.pcc"
719 #line 125 "parser-util.pcc"
720 VECTORpat(lookup_cons(a
), len
, array
, ps
, flex1
, flex2
)
721 #line 131 "parser-util.pcc"
722 #line 131 "parser-util.pcc"
725 Exp
mklistexp(Id cons
, Id nil
, Exps es
, Exp e
= NOexp
)
726 { return LISTexp(lookup_cons(cons
), lookup_cons(nil
), es
, e
);
728 Exp
mkappexp(Exp a
, Exp b
)
732 { IDexp id, RECORDexp _ | c = find_cons(id): { return CONSexp(c,#[],b); }
733 | _: { return APPexp(a,b); }
737 #line 144 "parser-util.pcc"
738 #line 146 "parser-util.pcc"
742 case a_Exp::tag_IDexp
: {
744 #line 145 "parser-util.pcc"
745 (c
= find_cons(((Exp_IDexp
*)a
)->IDexp
))
746 #line 145 "parser-util.pcc"
749 #line 145 "parser-util.pcc"
751 #line 145 "parser-util.pcc"
752 #line 145 "parser-util.pcc"
754 #line 145 "parser-util.pcc"
755 #line 145 "parser-util.pcc"
757 #line 145 "parser-util.pcc"
761 #line 146 "parser-util.pcc"
763 #line 146 "parser-util.pcc"
766 default: { goto L1
; } break;
770 #line 147 "parser-util.pcc"
771 #line 147 "parser-util.pcc"
774 Exp
mkvecexp(Id vec
, Exps es
)
775 { Used::vector
= true;
776 return VECTORexp(lookup_cons(vec
), es
);
778 TermDef
mklistterm(Id c
, Ty a
, Ty b
, Decls d
)
780 //{ ! DEFVALty _: { b = DEFVALty(b,LITERALexp(INTlit(0))); }
784 #line 158 "parser-util.pcc"
785 #line 158 "parser-util.pcc"
786 TERMdef(c
, mktuplety(list_1_(a
,list_1_(b
))), d
, nil_1_
, NOpat
, nil_1_
, OPTnone
, QUALnone
, NOexp
)
787 #line 158 "parser-util.pcc"
788 #line 158 "parser-util.pcc"
792 Exp
extupleexp(Exps es
) { mark_tuple_used(length(es
)); return EXTUPLEexp(es
); }
793 Pat
extuplepat(Pats ps
) { mark_tuple_used(length(ps
)); return EXTUPLEpat(ps
); }
794 Ty
extuplety(Tys ts
) { mark_tuple_used(length(ts
));
795 return TYCONty(EXTUPLEtycon
,ts
); }
797 ///////////////////////////////////////////////////////////////////////////////
798 // Function to build a piece of verbatim code.
799 ///////////////////////////////////////////////////////////////////////////////
800 Decls
PropParser::mkcode(Decls decls
)
801 { if (options
.emit_code
&& scan
.length() > 0) {
802 Decl code
= OPAQUEdecl(str_pool(scan
.text(),scan
.length()));
804 #line 172 "parser-util.pcc"
805 #line 172 "parser-util.pcc"
806 list_1_(mark(code
),decls
)
807 #line 172 "parser-util.pcc"
808 #line 172 "parser-util.pcc"
816 ///////////////////////////////////////////////////////////////////////////////
818 // Methods to increment the line count
820 ///////////////////////////////////////////////////////////////////////////////
821 void PropParser::count_lines ()
822 { for (const char * p
= lexbuf
.text(); *p
; p
++)
823 if (*p
== '\n') line
++;
826 ///////////////////////////////////////////////////////////////////////////////
827 // Method to lookup an expression from the pattern environment.
828 ///////////////////////////////////////////////////////////////////////////////
829 Exp
PropParser::lookup_exp(Id id
)
831 Exp e
= pv_env
.lookup(id
,&from_current
);
833 #line 195 "parser-util.pcc"
834 #line 201 "parser-util.pcc"
838 #line 201 "parser-util.pcc"
840 #line 201 "parser-util.pcc"
846 #line 197 "parser-util.pcc"
847 error ("%Lpattern variable '%s' has no binding at this point\n", id
);
850 #line 199 "parser-util.pcc"
853 #line 200 "parser-util.pcc"
855 #line 200 "parser-util.pcc"
860 #line 202 "parser-util.pcc"
861 #line 202 "parser-util.pcc"
865 ///////////////////////////////////////////////////////////////////////////////
866 // Type variable stack for building polymorphic type schemes.
867 ///////////////////////////////////////////////////////////////////////////////
868 Ty
PropParser::lookup_tyvar(Id id
)
869 { for (int i
= 0; i
< var_top
; i
++)
870 if (var_stack
[i
] == id
) return INDty(id
, i
);
872 #line 211 "parser-util.pcc"
873 #line 211 "parser-util.pcc"
875 #line 211 "parser-util.pcc"
876 #line 211 "parser-util.pcc"
880 Pat
PropParser::lookup_patvar(Id id
)
881 { for (int i
= 0; i
< var_top
; i
++)
882 if (var_stack
[i
] == id
) {
883 return pat_stack
[i
] == NOpat
884 ? (pat_stack
[i
] = INDpat(id
,i
,mkvar())) : pat_stack
[i
];
886 Pat scheme
= DatatypeCompiler::lookup_pat(id
);
887 if (scheme
!= NOpat
) {
888 return apply_pat(scheme
,NOpat
);
890 return IDpat(id
,mkvar(),NOexp
);
894 ///////////////////////////////////////////////////////////////////////////////
895 // Create a pattern from a constructor
896 ///////////////////////////////////////////////////////////////////////////////
897 Pat
PropParser::mkconspat(Cons cons
)
899 #line 232 "parser-util.pcc"
900 #line 242 "parser-util.pcc"
904 switch (cons
->alg_ty
->tag__
) {
905 case a_Ty::tag_TYCONty
: {
906 if (boxed(((Ty_TYCONty
*)cons
->alg_ty
)->_1
)) {
907 switch (((Ty_TYCONty
*)cons
->alg_ty
)->_1
->tag__
) {
908 case a_TyCon::tag_DATATYPEtycon
: {
910 #line 235 "parser-util.pcc"
911 ((((TyCon_DATATYPEtycon
*)((Ty_TYCONty
*)cons
->alg_ty
)->_1
)->qualifiers
& QUALlexeme
) && (match_kind
[me_top
] & MATCHscanner
))
912 #line 235 "parser-util.pcc"
915 #line 236 "parser-util.pcc"
916 if (cons
->lexeme_pattern
== NOpat
)
917 { error ("%Lpattern is undefined for lexeme %s\n",cons
->name
);
920 { return cons
->lexeme_pattern
; }
922 #line 241 "parser-util.pcc"
926 #line 242 "parser-util.pcc"
927 return CONSpat(cons
);
928 #line 242 "parser-util.pcc"
931 default: { goto L3
; } break;
935 default: { goto L3
; } break;
940 #line 243 "parser-util.pcc"
941 #line 243 "parser-util.pcc"
945 ///////////////////////////////////////////////////////////////////////////////
946 // Routine to add a new "$" variable binding
947 ///////////////////////////////////////////////////////////////////////////////
948 void PropParser::add_parse_stack_binding
949 (int item_number
, int symbol_number
, int nonterm_number
)
951 if (item_number
<= 0)
953 #line 253 "parser-util.pcc"
954 #line 253 "parser-util.pcc"
955 _p_a_r_s_e_rcn_u_t_i_lco_c_c_Q1
956 #line 253 "parser-util.pcc"
957 #line 253 "parser-util.pcc"
958 ,SYNexp(0,-symbol_number
,NOty
,false),junk_ty
);
961 #line 255 "parser-util.pcc"
962 #line 255 "parser-util.pcc"
963 _p_a_r_s_e_rcn_u_t_i_lco_c_c_Q2
964 #line 255 "parser-util.pcc"
965 #line 255 "parser-util.pcc"
967 SYNexp(nonterm_number
,-symbol_number
,NOty
,false),junk_ty
);
970 ///////////////////////////////////////////////////////////////////////////////
971 // Error handler for the parser
972 ///////////////////////////////////////////////////////////////////////////////
973 PropParser::ErrorAction
PropParser::error_report(const char * message
)
974 { if (meta
.length() > 0)
975 { error ("%L%s at quotation text `%s`, ", message
, meta
.text());
977 } else if (lexbuf
.length() == 0)
978 { error ("%L%s at end of file, ", message
);
980 { error ("%L%s at token \"%s\", ", message
, lexbuf
.text());
985 ///////////////////////////////////////////////////////////////////////////////
987 // Method to initialize the lexer
989 ///////////////////////////////////////////////////////////////////////////////
990 void PropParser::initialize_lexer (const char * initial_file_name
)
991 { if (initial_file_name
== 0) initial_file_name
= "<stdin>";
992 file
= initial_file_name
; line
= first_line
= 1;
996 options
.emit_code
= true;
998 #line 286 "parser-util.pcc"
999 #line 286 "parser-util.pcc"
1001 #line 286 "parser-util.pcc"
1002 #line 286 "parser-util.pcc"
1004 levels
[levels_top
++] = -1;
1005 lexbuf
.set_context(C
);
1006 lexbuf
.set_stream(*input_stream
);
1009 ///////////////////////////////////////////////////////////////////////////////
1011 // Method to cleanup the lexer
1013 ///////////////////////////////////////////////////////////////////////////////
1014 void PropParser::cleanup_lexer()
1015 { while (quote_top
!= 0)
1016 { const Quote
& quote
= quote_stack
[--quote_top
];
1018 loc
.file_name
= quote
.file_name
;
1019 loc
.begin_line
= quote
.line_number
;
1020 loc
.end_line
= quote
.line_number
;
1021 error ("%!unbalanced %c ... %c at end of file\n",
1022 &loc
, (int)quote
.open
, (int)quote
.close
);
1026 ///////////////////////////////////////////////////////////////////////////////
1028 // Method to open a new include file
1030 ///////////////////////////////////////////////////////////////////////////////
1031 void PropParser::open_include_file(const char * file_name
)
1032 { for (int i
= 0; i
< included_count
; i
++)
1033 if (included_files
[i
] == file_name
) return;
1034 std::istream
* new_stream
= options
.open_input_file(file_name
);
1035 if (options
.gen_dependences
)
1036 IncludeDependency::add_dependency(str_pool
[options
.current_file_path
]);
1037 if (new_stream
== 0)
1038 { error ("%Lcan't find include file \"%s\"\n", file_name
);
1041 if (includes_top
>= MAX_INCLUDE_FILES
) bug ("Include file stack overflow");
1042 if (included_count
>= MAX_INCLUDE_FILES
) bug ("Too many include files");
1043 included_files
[included_count
++] = file_name
;
1044 includes
[includes_top
].file_stream
= input_stream
;
1045 includes
[includes_top
].file
= file
;
1046 includes
[includes_top
].line
= line
;
1047 includes
[includes_top
].first_line
= first_line
;
1048 includes
[includes_top
].scan
= scan
;
1049 includes
[includes_top
].doc
= doc
;
1050 includes
[includes_top
].meta
= meta
;
1055 options
.emit_code
= false;
1056 input_stream
= new_stream
;
1057 lexbuf
.push_stream(*input_stream
);
1058 lexbuf
.set_context(C
);
1061 ///////////////////////////////////////////////////////////////////////////////
1063 // Method to open a new include file
1065 ///////////////////////////////////////////////////////////////////////////////
1066 void PropParser::close_include_file()
1067 { if (includes_top
<= 0) bug("Include file stack underflow");
1069 debug_msg("[Closing \"%s\" %i lines]\n", file
, line
-1);
1070 delete input_stream
;
1071 input_stream
= includes
[includes_top
].file_stream
;
1072 file
= includes
[includes_top
].file
;
1073 line
= includes
[includes_top
].line
;
1074 first_line
= includes
[includes_top
].first_line
;
1075 scan
= includes
[includes_top
].scan
;
1076 doc
= includes
[includes_top
].doc
;
1077 meta
= includes
[includes_top
].meta
;
1078 options
.emit_code
= includes_top
== 0;
1079 input_stream
= &lexbuf
.pop_stream();
1082 ///////////////////////////////////////////////////////////////////////////////
1084 // Methods to append text to the code buffer.
1086 ///////////////////////////////////////////////////////////////////////////////
1087 void PropParser::emit ()
1088 { emit(lexbuf
.text(), lexbuf
.length()); }
1090 void PropParser::emit (const char * t
, long len
)
1091 { if (options
.emit_code
) scan
.emit(t
,len
); }
1093 void PropParser::emit (char c
)
1094 { if (options
.emit_code
) scan
.emit(c
); }
1096 void PropParser::emit_header ()
1097 { if (options
.emit_code
)
1098 compiler
->emit_header(lexbuf
.text()+2,lexbuf
.length()-2);
1101 // Append an expression
1102 void PropParser::emit(Exp e
)
1103 { std::ostrstream b
;
1104 std::ostream
& f
= b
;
1105 f
<< e
<< std::ends
;
1107 b
.rdbuf()->freeze(0); // free buffer
1110 // Append a constructor expression
1111 void PropParser::emit_cons(Id cons_name
)
1112 { lookup_cons(cons_name
);
1113 emit(mangle(cons_name
));
1116 ///////////////////////////////////////////////////////////////////////////////
1118 // Methods to enter/exit a lexical context.
1120 ///////////////////////////////////////////////////////////////////////////////
1121 void PropParser::start_sc(LexicalContext c
)
1122 { SCs
[SCs_top
++] = LexicalContext(lexbuf
.context()); lexbuf
.set_context(c
);
1123 // if (options.debug) cerr << "[+context " << c << "]";
1126 void PropParser::end_sc()
1128 { --SCs_top
; lexbuf
.set_context(SCs
[SCs_top
]); }
1129 // if (options.debug) cerr << "[-context " << SCs[SCs_top] << "]";
1132 ///////////////////////////////////////////////////////////////////////////////
1134 // Methods to enter/exit a statement
1136 ///////////////////////////////////////////////////////////////////////////////
1137 void PropParser::start_statement()
1138 { levels
[levels_top
++] = quote_top
; start_sc(C
); }
1140 void PropParser::end_statement()
1143 ///////////////////////////////////////////////////////////////////////////////
1145 // Methods to push and pop from the quotation stack
1147 ///////////////////////////////////////////////////////////////////////////////
1148 void PropParser::start_quote(char a
, char b
)
1149 { quote_stack
[quote_top
++] = Quote(file
,line
,a
,b
);
1152 char PropParser::end_quote(char c
)
1153 { if (quote_top
== 0)
1154 { error("%Lunmatched ending quote %c\n",c
);
1157 { const Quote
& quote
= quote_stack
[quote_top
-1];
1158 if (quote
.close
!= c
)
1159 { error("%Lexpecting %c ... %c (from line %i) but found %c ... %c instead\n",
1160 (int)quote
.open
, (int)quote
.close
, quote
.line_number
,
1161 (int)quote
.open
, (int)c
);
1167 #line 450 "parser-util.pcc"
1169 ------------------------------- Statistics -------------------------------
1170 Merge matching rules = yes
1171 Number of DFA nodes merged = 101
1172 Number of ifs generated = 7
1173 Number of switches generated = 4
1174 Number of labels = 3
1176 Adaptive matching = enabled
1177 Fast string matching = disabled
1178 Inline downcasts = enabled
1179 --------------------------------------------------------------------------