parser formatting to look lkike a huge comment to C editors

pull/111/merge
Ondřej Hruška 7 years ago
parent b48bb12067
commit 373affb582
  1. 36
      user/ansi_parser.c
  2. 8
      user/ansi_parser.rl

@ -229,19 +229,19 @@ execFuncs:
while ( _nacts-- > 0 ) { while ( _nacts-- > 0 ) {
switch ( *_acts++ ) { switch ( *_acts++ ) {
case 0: case 0:
/* #line 54 "user/ansi_parser.rl" */ /* #line 55 "user/ansi_parser.rl" */
{ {
apars_handle_plainchar((*p)); apars_handle_plainchar((*p));
} }
break; break;
case 1: case 1:
/* #line 61 "user/ansi_parser.rl" */ /* #line 62 "user/ansi_parser.rl" */
{ {
/* Reset the CSI builder */ // Reset the CSI builder
csi_leading = csi_char = 0; csi_leading = csi_char = 0;
csi_ni = 0; csi_ni = 0;
/* Zero out digits */ // Zero out digits
for(int i = 0; i < CSI_N_MAX; i++) { for(int i = 0; i < CSI_N_MAX; i++) {
csi_n[i] = 0; csi_n[i] = 0;
} }
@ -250,28 +250,28 @@ execFuncs:
} }
break; break;
case 2: case 2:
/* #line 74 "user/ansi_parser.rl" */ /* #line 75 "user/ansi_parser.rl" */
{ {
csi_leading = (*p); csi_leading = (*p);
} }
break; break;
case 3: case 3:
/* #line 78 "user/ansi_parser.rl" */ /* #line 79 "user/ansi_parser.rl" */
{ {
/* x10 + digit */ // x10 + digit
if (csi_ni < CSI_N_MAX) { if (csi_ni < CSI_N_MAX) {
csi_n[csi_ni] = csi_n[csi_ni]*10 + ((*p) - '0'); csi_n[csi_ni] = csi_n[csi_ni]*10 + ((*p) - '0');
} }
} }
break; break;
case 4: case 4:
/* #line 85 "user/ansi_parser.rl" */ /* #line 86 "user/ansi_parser.rl" */
{ {
csi_ni++; csi_ni++;
} }
break; break;
case 5: case 5:
/* #line 89 "user/ansi_parser.rl" */ /* #line 90 "user/ansi_parser.rl" */
{ {
csi_char = (*p); csi_char = (*p);
@ -281,14 +281,14 @@ execFuncs:
} }
break; break;
case 6: case 6:
/* #line 97 "user/ansi_parser.rl" */ /* #line 98 "user/ansi_parser.rl" */
{ {
apars_handle_badseq(); apars_handle_badseq();
{cs = 1;goto _again;} {cs = 1;goto _again;}
} }
break; break;
case 7: case 7:
/* #line 114 "user/ansi_parser.rl" */ /* #line 115 "user/ansi_parser.rl" */
{ {
csi_ni = 0; csi_ni = 0;
@ -301,14 +301,14 @@ execFuncs:
} }
break; break;
case 8: case 8:
/* #line 125 "user/ansi_parser.rl" */ /* #line 126 "user/ansi_parser.rl" */
{ {
apars_handle_OSC_FactoryReset(); apars_handle_OSC_FactoryReset();
{cs = 1;goto _again;} {cs = 1;goto _again;}
} }
break; break;
case 9: case 9:
/* #line 130 "user/ansi_parser.rl" */ /* #line 131 "user/ansi_parser.rl" */
{ {
apars_handle_OSC_SetScreenSize(csi_n[0], csi_n[1]); apars_handle_OSC_SetScreenSize(csi_n[0], csi_n[1]);
@ -316,7 +316,7 @@ execFuncs:
} }
break; break;
case 10: case 10:
/* #line 141 "user/ansi_parser.rl" */ /* #line 142 "user/ansi_parser.rl" */
{ {
// Reset screen // Reset screen
apars_handle_RESET_cmd(); apars_handle_RESET_cmd();
@ -324,14 +324,14 @@ execFuncs:
} }
break; break;
case 11: case 11:
/* #line 147 "user/ansi_parser.rl" */ /* #line 148 "user/ansi_parser.rl" */
{ {
apars_handle_saveCursorAttrs(); apars_handle_saveCursorAttrs();
{cs = 1;goto _again;} {cs = 1;goto _again;}
} }
break; break;
case 12: case 12:
/* #line 152 "user/ansi_parser.rl" */ /* #line 153 "user/ansi_parser.rl" */
{ {
apars_handle_restoreCursorAttrs(); apars_handle_restoreCursorAttrs();
{cs = 1;goto _again;} {cs = 1;goto _again;}
@ -355,7 +355,7 @@ _again:
while ( __nacts-- > 0 ) { while ( __nacts-- > 0 ) {
switch ( *__acts++ ) { switch ( *__acts++ ) {
case 6: case 6:
/* #line 97 "user/ansi_parser.rl" */ /* #line 98 "user/ansi_parser.rl" */
{ {
apars_handle_badseq(); apars_handle_badseq();
{cs = 1; if ( p == pe ) {cs = 1; if ( p == pe )
@ -371,6 +371,6 @@ goto _again;}
_out: {} _out: {}
} }
/* #line 171 "user/ansi_parser.rl" */ /* #line 173 "user/ansi_parser.rl" */
} }

@ -45,6 +45,7 @@ ansi_parser(const char *newdata, size_t len)
// The parser // The parser
%%{ %%{
#/*
ESC = 27; ESC = 27;
NOESC = (any - ESC); NOESC = (any - ESC);
TOK_ST = ESC '\\'; # String terminator - used for OSC commands TOK_ST = ESC '\\'; # String terminator - used for OSC commands
@ -59,11 +60,11 @@ ansi_parser(const char *newdata, size_t len)
# Text color & style # Text color & style
action CSI_start { action CSI_start {
/* Reset the CSI builder */ // Reset the CSI builder
csi_leading = csi_char = 0; csi_leading = csi_char = 0;
csi_ni = 0; csi_ni = 0;
/* Zero out digits */ // Zero out digits
for(int i = 0; i < CSI_N_MAX; i++) { for(int i = 0; i < CSI_N_MAX; i++) {
csi_n[i] = 0; csi_n[i] = 0;
} }
@ -76,7 +77,7 @@ ansi_parser(const char *newdata, size_t len)
} }
action CSI_digit { action CSI_digit {
/* x10 + digit */ // x10 + digit
if (csi_ni < CSI_N_MAX) { if (csi_ni < CSI_N_MAX) {
csi_n[csi_ni] = csi_n[csi_ni]*10 + (fc - '0'); csi_n[csi_ni] = csi_n[csi_ni]*10 + (fc - '0');
} }
@ -168,5 +169,6 @@ ansi_parser(const char *newdata, size_t len)
)+ $!errBadSeq; )+ $!errBadSeq;
write exec; write exec;
#*/
}%% }%%
} }

Loading…
Cancel
Save