[antlr-interest] Code beautifier-indentation

Meena Moktali mmoktali at bphx.dk
Thu Mar 17 08:18:17 PST 2005


hi John,
The final goal is to indent the code according to standards for each block.
I can give u an example as below..
Can u help me with this?

Meena

ORIGINAL CODE  (no indentation followed)
-------------

if L_RTRN_CD = SUCCESS in STD_RTRN_CD
*> Corebank account or currency are required <*
if (ACT_RECVD_CLRG_ID of ACCTG_TRANS_PD_WD of ACCTG_TRANS_PD_W
= ' '
or ARID_ITEM of ACCTG_TRANS_PD_WD of ACCTG_TRANS_PD_W
= ' ')
and
PSTG_ORGNL_ISO4217 of ACCTG_TRANS_PD_WD of ACCTG_TRANS_PD_W
= ' '
map EITHER_ACCOUNT_OR_CURRENCY in KSPS8_MSG
to TEXT_CODE of STD_MSG_PARM_V of STD_MSG_CLIENT_SRV_I
map 'ACCTG_TRANS_PD_WD'
to VIEW_LONG_NAME of STD_MSG_CLIENT_SRV_I
map BUSINESS_ERROR in STD_RTRN_CD
to L_RTRN_CD
map 'ACT_RECVD_CLRG_ID'
to FIELD_LONG_NAME of STD_MSG_CLIENT_SRV_I
map 'ADZRLP'
to MESSAGE_SET_NAME of STD_MSG_PARM_V of STD_MSG_CLIENT_SRV_I
  endif
endif

BEAUTIFIED CODE
---------------

if L_RTRN_CD = SUCCESS in STD_RTRN_CD
  *> Corebank account or currency are required <*
  if (ACT_RECVD_CLRG_ID of ACCTG_TRANS_PD_WD of ACCTG_TRANS_PD_W
     = ' '
     or ARID_ITEM of ACCTG_TRANS_PD_WD of ACCTG_TRANS_PD_W
     = ' ')
  and
    PSTG_ORGNL_ISO4217 of ACCTG_TRANS_PD_WD of ACCTG_TRANS_PD_W
     = ' '
    map EITHER_ACCOUNT_OR_CURRENCY in KSPS8_MSG
       to TEXT_CODE of STD_MSG_PARM_V of STD_MSG_CLIENT_SRV_I
    map 'ACCTG_TRANS_PD_WD'
       to VIEW_LONG_NAME of STD_MSG_CLIENT_SRV_I
    map BUSINESS_ERROR in STD_RTRN_CD
       to L_RTRN_CD
    map 'ACT_RECVD_CLRG_ID'
       to FIELD_LONG_NAME of STD_MSG_CLIENT_SRV_I
    map 'ADZRLP'
       to MESSAGE_SET_NAME of STD_MSG_PARM_V of STD_MSG_CLIENT_SRV_I

  endif
endif
       


-----Original Message-----
From: John D. Mitchell [mailto:johnm-antlr at non.net]
Sent: 17. marts 2005 17:00
To: Meena Moktali
Cc: antlr-interest at antlr.org
Subject: [antlr-interest] Code beautifier-indentation


>>>>> "Meena" == Meena Moktali <mmoktali at bphx.dk> writes:
[...]

> HI, I am a newby in ANTLR.I am trying to write a grammar for code
> beautification(proper indentation )according to the looping strutures.
> The source code is that of AppBilder rule(having its own language syntax
> ,similar to HTML).

> Can anybody suggest some sample code or ideas of how to go about this?

How complex is the "beautification"?  I.e., are you literally only changing
indentation or do you need to completely reformat the code?  If it's the
first, you can take some really simple approaches but if it's the latter
than you're into the world of full-on source-to-source transformation.

Take care,
	John


More information about the antlr-interest mailing list