/* Copyright Dave Bone 1998 - 2014 All Rights Reserved. No part of this document may be reproduced without written consent from the author. FILE: cweave_fsm_sdc.lex Dates: 13 Jan. 2006 Purpose: write out cweave sentence for syntax directed directives of fsm */ /@ @i "/usr/local/yacco2/copyright.w" @** |cweave_fsm_sdc| grammar.\fbreak Write out cweave fsm directives sentences. @/ fsm (fsm-id "cweave_fsm_sdc.lex" ,fsm-filename cweave_fsm_sdc ,fsm-namespace NS_cweave_fsm_sdc ,fsm-class Ccweave_fsm_sdc{ user-prefix-declaration #include "o2_externs.h" *** user-declaration public: std::ofstream* cweave_file_; T_fsm_phrase* fsm_phrase_; void initialize (std::ofstream* Cweave_file ,T_fsm_phrase* Fsm_phrase); void output_sr_sdcode(const char* Directive); void output_sr_sdcode_title(const char* Directive); void wrt_directive(const char* Directive,T_syntax_code* Sdc); *** user-implementation void Ccweave_fsm_sdc::initialize (std::ofstream* Cweave_file ,T_fsm_phrase* Fsm_phrase){ cweave_file_ = Cweave_file; fsm_phrase_ = Fsm_phrase; } /@ @*3 |wrt_directive|. @/ void Ccweave_fsm_sdc::wrt_directive(const char* Directive,T_syntax_code* Sdc){ output_sr_sdcode_title(Directive); if(Sdc == 0){ output_sr_sdcode(Directive); (*cweave_file_) << "/"; (*cweave_file_) << "/ no sdcode" << endl; return; } if(Sdc->cweb_marker() != 0){ WRT_CWEB_MARKER(cweave_file_,Sdc->cweb_marker()); } output_sr_sdcode(Directive); string xlate; int len = Sdc->syntax_code()->length(); string& sdc=*Sdc->syntax_code(); // prescan @ due to cweave reqmts for(int x=0;x')){ xlate += nc; continue; }else{ xlate += "@@"; continue; } }else{ xlate += nc; continue; } } (*cweave_file_) << xlate.c_str() << endl; } /@ @*3 |output_sr_sdcode|. @/ void Ccweave_fsm_sdc::output_sr_sdcode(const char* Directive){ char big_buf_[BIG_BUFFER_32K]; char xa[Max_cweb_item_size]; XLATE_SYMBOLS_FOR_cweave (fsm_phrase_->fsm_class_phrase()->identifier()->identifier()->c_str() ,xa); KCHARP cweave_sentence = "@<%s %s directive@>=\n"; sprintf(big_buf_ ,cweave_sentence ,xa ,Directive ); (*cweave_file_) << big_buf_; } /@ @*3 |output_sr_sdcode_title|. @/ void Ccweave_fsm_sdc::output_sr_sdcode_title(const char* Directive){ char big_buf_[BIG_BUFFER_32K]; char xa[Max_cweb_item_size]; XLATE_SYMBOLS_FOR_cweave (fsm_phrase_->fsm_class_phrase()->identifier()->identifier()->c_str() ,xa); KCHARP cweave_sentence = "@*3 %s %s directive.\n"; sprintf(big_buf_ ,cweave_sentence ,xa ,Directive ); (*cweave_file_) << big_buf_; } *** } ,fsm-version "1.0",fsm-date "5 Jan. 2006",fsm-debug "false" ,fsm-comments "Write out cweave fsm directives sentences.") @"/usr/local/yacco2/compiler/grammars/yacco2_T_includes.T" // rules{ Rweave_fsm_sdc (){ -> Rdirectives eog } Rdirectives (){ -> Rdirective -> Rdirectives Rdirective } Rdirective (){ -> "#user-declaration" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "user-declaration"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#user-prefix-declaration" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "user-prefix-declaration"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#user-suffix-declaration" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "user-suffix-declaration"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#constructor" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "constructor"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#destructor" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; const char* sdc = "destructor"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#op" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "op"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#failed" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; const char* sdc = "failed"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#user-implementation" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; const char* sdc = "user-implementation"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#user-imp-tbl" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "user-imp-tbl"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } -> "#user-imp-sym" { op Ccweave_fsm_sdc* fsm = (Ccweave_fsm_sdc*)rule_info__.parser__->fsm_tbl__; KCHARP sdc = "user-imp-sym"; fsm->wrt_directive(sdc,sf->p1__->syntax_code()); *** } } }// end of rules