Syntax highlighting using Mediawiki formatting: Difference between revisions

Content added Content deleted
(→‎{{header|Wren}}: Now allows for nesting of multi-line comments.)
Line 183: Line 183:
'''BEGIN''' \
'''BEGIN''' \
{
{
''# reserved word list as in gawk and treating getline as reserved ''
''# reserved word list as in gawk and treating getline as reserved ''
kw = "BEGIN/BEGINFILE/END/ENDFILE/" \
kw = "BEGIN/BEGINFILE/END/ENDFILE/" \
Line 197: Line 196:
} ''# BEGIN''
} ''# BEGIN''
{
{
printf( " " );
printf( " " );
line = $0;
line = $0;
Line 225: Line 224:
'''if'''( c == "\\" )
'''if'''( c == "\\" )
{
{
printf( "%s", c );
outAndNextChar();
nextChar();
}
}
printf( "%s", c );
outAndNextChar();
nextChar();
}
}
'''while'''( c != "\"" && c != "" );
'''while'''( c != "\"" && c != "" );
Line 246: Line 243:
''# pattern''
''# pattern''
bracketDepth = 0;
bracketDepth = 0;
printf( "%s", c );
outAndNextChar();
nextChar();
'''while'''( c != "" && ( c != "/" || bracketDepth > 0 ) )
'''while'''( c != "" && ( c != "/" || bracketDepth > 0 ) )
{
{
'''if'''( c == "\\" || c == "[" )
'''if'''( c == "\\" || c == "[" )
{
{
'''if''' ( c == "[" )
'''if'''( c == "[" )
{
{
bracketDepth ++;
bracketDepth ++;
}
}
printf( "%s", c );
outAndNextChar();
nextChar();
}
}
'''else''' '''if'''( c == "]" )
'''else''' '''if'''( c == "]" )
Line 263: Line 258:
bracketDepth --;
bracketDepth --;
}
}
printf( "%s", c );
outAndNextChar();
nextChar();
}
}
'''if'''( c != "/" )
'''if'''( c != "/" )
Line 295: Line 289:
{
{
''# something else''
''# something else''
printf( "%s", c );
outAndNextChar();
nextChar();
}
}
}
}
Line 303: Line 296:
printf( "\n" );
printf( "\n" );
}
'''function''' outAndNextChar()
{
printf( "%s", c );
nextChar();
}
}
Line 315: Line 314:
{
{
''# at end of line''
''# at end of line''
c = "";
lastC = c = "";
}
}
'''else'''
'''else'''