flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Macrolinstruction to C-style comment IN FASMG

Author
Thread Post new topic Reply to topic
Dima1205



Joined: 02 Jul 2023
Posts: 23
Location: Russian, Moscow
Dima1205 10 Jul 2024, 23:59
Macrolinstruction to C-style comment
Code:
 ;Специальная константа - для многострочных комментариев:
 STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ 
;
; Многострочные комментарии из языка СИ!!!
;

macro ? line&

 match  ,line

    line
 ;
 ;Однострочный комментарий из языка Си:
 ;
 else match //,line

 else match //value,line

 else match str//value,line
       str
 else match str//,line
      str
 ;
 ;Многострочный комментарий из языка Си:
 ;
 else
     ;
     ;Сверяем начало строки СИ!!!
     ;
     match /*,line
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ 1

     else match /*value,line
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ 1

     else match str/*value,line
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ 1
         str

     else match str/*,line
         str
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ 1

     end match
     ;Выводим строку, если сигнальная константа не равна 1:
     match ,STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST

         line

     end match
     ;
     ; проверяем ранее созданную константу:
     ;
     match */,line
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ

     else match value*/,line
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ

     else match str*/value,line
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ
         value

     else match */str,line
         str
         STR_C_POWER_MULTILINE_STRING_ULTIMAE_CONST equ

     end match

 end match

end macro    
    

примеры использования:
Code:
 //
 // test hkbnf kjnkj hkibnhi jini hinhi jbni nki iubni nui juinui juini kjuini uihnui uinui juinui uinui injui uin
 // kjmom oko okm,o oim,o
 // momol ojmoij oimjo oim oimo
 // oi oikoi pokpok pokpo
 // callmaxcro jb kjhn
 //

 /*
   ykjrt macro yui
   675 fbgdsf
   dfs
   fdsg
   dgs
   gsd
   hjbj
   jnm
   kio
   pokmjpo
   pok
   pok
   pok
   pok
*/        
    

Успешно тестировал на fasmg. В идеале думаю, ещё остальные директивы языка C перенести.

_________________
Best regards, Dmitry
Post 10 Jul 2024, 23:59
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3977
Location: vpcmipstrm
bitRAKE 11 Jul 2024, 04:13
Code:
calminstruction calminstruction?.initsym? variable*,value&
        publish variable, value
end calminstruction

calminstruction ? line&
        local multi,part,rest
        initsym multi,0

        arrange part,
        arrange rest,
        check multi
        jno start
        match any? */ part?,line
        jno done
all:    compute multi,multi xor 1
clip:   arrange line, part rest
        assemble line
done:   exit

start:  match // any?, line
        jyes done
        match part? /* any? */ rest?, line
        jyes clip
        match part? /* any?, line
        jyes all
        match part? // any?, line
        jyes clip
        assemble line
end calminstruction    
Very Happy
Code:
// Just test a variety of uses ...

display 'I think this will work',10 // just keep trying ...

display 'another' /* Some block stuff,
   we just keep typing */ display ' test',10

//  /* what happens here?
//  what happens here? */

/*
//
// lets try to make it more difficult
//
*/

display 'more', /* inline */ ' testing is needed',10

/**/    
By no means is this working in all cases:
Code:
/*
*/ display 'fail',10 /*
*/    
... nesting is a little more difficult. /* /* */ */

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 11 Jul 2024, 04:13
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.