#% text_encoding = iso8859_1 # Copyright (C) Field Consulting and Services, Inc., 2018 all rights reserved. ######################################################################## ## ## Created By: Mark Field (FCSI) ## Date: 2018/06/19 ## Last Modified Time-stamp: <06/19/2018 13:47, Mark Field (FCSI)> ## ## Project Files ## ## Description: ## This is to support the new "_class" directive in smallworld ## 5.1.4+ in 4.3. Note that the class is ignored and only ## supports 1 class directive. Since this is to support ## backward compatibility, it isn't truly robust. ## ## The following works: ## def_slotted_exemplar(:exemplar, ## { ## },{:plugin}, ## { _class |com.gesmallworld.magik.language.MagikFinalisable|} ## ) ## def_slotted_exemplar(:exemplar, ## { ## },{:plugin},{ _class |com.gesmallworld.magik.language.MagikFinalisable|} ## ) ## ## The following does not work... ## def_slotted_exemplar(:exemplar, ## { ## },{:plugin},{ ## _class |com.gesmallworld.magik.language.MagikFinalisable|} ## ) $ ######################################################################## _package sw $ user:fcsi_method_manip.fcsi_copy_method(magik_parser,:|lookahead()|) $ _pragma(classify_level=restricted) _method magik_parser.lookahead() _local lal << _self.sw!lookahead() _if lal.type _is :bad _then _return _self.fcsi_try_to_ignore_class_lookahead() _endif _return lal _endmethod $ _pragma(classify_level=restricted) _method magik_parser.fcsi_try_to_ignore_class_lookahead() ## Parameters : none ## Returns : lexeme of :rcurley ## Function : handles a _class directive on same line as {} ## See file description for examples that work in 4.3 ## Methodology : #---------------- HISTORY --------------------- # (2018/06/19 - Mark Field (FCSI)): Created. #---------------------------------------------- #DEBUG _global !a; !a << {_self.copy(),.input.copy(),.current_mark.copy()} _local cLine << .current_mark.text[.current_mark.line] # Tried to handle separate lines, but ran out of time... #_local unget? << _false _try _if cLine.subseq(.current_lex.startcol,.current_lex.length) <> "_class" _then _return .lookahead_lex _endif _when index_out_of_bounds # unget? << _true # .input.get() # cLine << .current_mark.text[.current_mark.line] # _if cLine.subseq(.current_lex.startcol,.current_lex.length) <> "_class" # _then # .input.unget() _return .lookahead_lex # _endif _endtry _local endPipe << cLine.rindex_of(%|) _local nLine << cLine.subseq(1,.current_lex.startcol-1) _local rCurleyPos << nLine.size nLine +<< cLine.subseq(endPipe+1) .input.sys!slot(:text)[.current_mark.line] << nLine .input.sys!slot(:lex)[.current_mark.line][.current_mark.lex] << lexeme.new(:rcurly,_unset,_unset,rCurleyPos,1) .input.scan_line(.current_mark.line) #DEBUG !a << {_self.copy(),.input.copy(),.current_mark.copy()} .current_lex << .lookahead_lex << .input.sys!slot(:lex)[.current_mark.line][.current_mark.lex] _return .lookahead_lex _endmethod $