Simple Preprocessor

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

Preprocess all input lines using the following steps:

1. Trim all tabs and spaces from the beginning and end of the line
2. If the line is not empty and doesn't start with #, output the line.

Options

exec is denied

now post-mortem time, all source codes will be revealed

Sample input:_

#=======================================
#Preprocessor test file and preprocessor
#=======================================

#Define application attributes
*application 'preprocessor' has entry 'start' and has exit 'finish'
*functionality 'console'
*add module 'core'
*add module 'streams'
*add module 'strings'
	
#Define entry point
fixed function->start [no arguments, no value]   
	#Open standard input and output
	stream->stdin = getstd(0) 
	stream->stdout = getstd(1)
	#Loop until EOF
	fixed loop [exit on stdin@readline(empty) as string->line is null]	
	  	#Open an edit block to perform operations only on line	 	
		fixed edit line
			 #Remove all leading and trailing tabs and spaces 
			fixed loop [exit on @characters(0) as character->check is not in {' ','	'}, exit on @length@value as integer->size is not 0]
				@start@modify(@start@value + 1)
			complete
   	 	  	fixed loop [exit on @characters(@length@value - 1) as character->check is not in {' ','	'}, exit on @length@value as integer->size is not 0]  	
				@length@modify(@length@value - 1)	
			complete 				
		complete
		#Check if the line is not empty
        	fixed skip [execute on line@length@value as integer->temp is not 0]
			#Check if the line doesn't start with a hash symbol
			fixed skip [execute on line@characters(line@length@value - 1) as character->check is not '#']
				#Write the new line to the output
				stdout@writeline(line)
			complete
		complete
	complete
	#Close and finalize all streams
	stdin@close(empty)
        stdout@flush(empty)
	stdout@eof(empty)
	stdout@close(empty)
	#Clean all variables from memory
	destroy {stdin, stdout}
	#Exit the function	
	exit(empty)
complete
  	 
#Define exit point
fixed function->finish [no arguments, value is integer]
	#Return successful exit code
	exit(0)
complete

Sample output:

*application 'preprocessor' has entry 'start' and has exit 'finish'
*functionality 'console'
*add module 'core'
*add module 'streams'
*add module 'strings'
fixed function->start [no arguments, no value]
stream->stdin = getstd(0)
stream->stdout = getstd(1)
fixed loop [exit on stdin@readline(empty) as string->line is null]
fixed edit line
fixed loop [exit on @characters(0) as character->check is not in {' ','	'}, exit on @length@value as integer->size is not 0]
@start@modify(@start@value + 1)
complete
fixed loop [exit on @characters(@length@value - 1) as character->check is not in {' ','	'}, exit on @length@value as integer->size is not 0]
@length@modify(@length@value - 1)
complete
complete
fixed skip [execute on line@length@value as integer->temp is not 0]
fixed skip [execute on line@characters(line@length@value - 1) as character->check is not '#']
stdout@writeline(line)
complete
complete
complete
stdin@close(empty)
stdout@flush(empty)
stdout@eof(empty)
stdout@close(empty)
destroy {stdin, stdout}
exit(empty)
complete
fixed function->finish [no arguments, value is integer]
exit(0)
complete

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1clock300.01842012/08/02 07:19:470B / 19B / 10B
2leonid300.02852012/08/02 09:56:260B / 19B / 10B

Perl _

RankUserSizeTimeDateStatistics
1tails310.04182012/08/09 21:03:230B / 10B / 19B
2ais523320.01092012/08/15 15:22:400B / ?B / ?B
3shlomif340.01112012/08/13 03:16:490B / 10B / 21B
4tanon350.01122012/08/11 18:27:510B / ?B / ?B
5jonathan camacho370.01132014/01/19 05:32:030B / 11B / 23B
6BioFALSE420.02172012/12/04 22:49:420B / 15B / 27B

Python _

RankUserSizeTimeDateStatistics
1clock480.01752012/08/02 07:17:390B / 29B / 13B
2hallvabo480.01882012/08/02 07:51:110B / 29B / 13B
3leonid480.02632012/08/02 09:56:430B / 29B / 13B
4twobit480.02032012/08/03 10:21:090B / 29B / 13B
5Hendrik480.01662012/08/10 01:16:170B / 29B / 13B
6recursive630.01982012/08/15 00:10:100B / 36B / 18B

PHP _

RankUserSizeTimeDateStatistics
1clock500.02262012/08/10 17:29:061B / 25B / 23B

Scheme _

RankUserSizeTimeDateStatistics
1kaki590.02162013/03/25 05:17:110B / 22B / 37B

Io _

RankUserSizeTimeDateStatistics
1pooq620.08812012/10/07 02:35:020B / 46B / 12B

JavaScript _

RankUserSizeTimeDateStatistics
1clock410.01912012/08/02 07:44:210B / 23B / 18B
20mg410.02382012/08/02 16:02:540B / 23B / 18B
3Hendrik410.01832012/08/10 15:40:180B / 23B / 18B
4nn410.01682012/08/11 22:55:470B / 23B / 18B
5Shmiddty410.02572013/12/20 13:51:420B / 23B / 18B

Lua _

RankUserSizeTimeDateStatistics
1clock450.04362012/08/14 16:04:480B / 22B / 23B
2twobit600.01262012/08/03 10:29:300B / 36B / 22B
3yamaya600.01082012/08/11 13:55:530B / 25B / 35B

Tcl _

RankUserSizeTimeDateStatistics
1clock690.02212012/08/11 16:22:350B / 33B / 29B

Kite _

RankUserSizeTimeDateStatistics
1clock742.78492012/08/10 16:47:030B / 42B / 30B
2teebee750.31642012/08/03 22:55:360B / 38B / 35B

SNOBOL _

RankUserSizeTimeDateStatistics
1clock700.01132012/08/10 17:53:480B / 35B / 20B

Icon _

RankUserSizeTimeDateStatistics
1clock810.01032012/08/02 16:33:480B / 45B / 32B

J _

RankUserSizeTimeDateStatistics
1I., S.500.02752012/08/05 05:39:070B / 8B / 40B

K _

RankUserSizeTimeDateStatistics
1teebee410.00422012/08/03 07:51:010B / 8B / 32B
2av470.02062012/08/03 08:51:200B / 9B / 37B

C _

RankUserSizeTimeDateStatistics
1david_werecat1100.01072012/08/14 23:01:090B / 55B / 55B
2Y.OHNO1200.01072012/08/13 17:39:200B / 54B / 66B
3david_werecat (usable)1210.01062012/08/14 23:06:070B / 60B / 60B
4david_werecat (Y.OHNO)1050.01062012/08/16 05:46:260B / 52B / 53B

Haskell _

RankUserSizeTimeDateStatistics
1henkma740.01502012/08/06 19:52:550B / 50B / 23B

C# _

RankUserSizeTimeDateStatistics
1Hendrik1200.06882012/08/15 00:59:110B / 77B / 38B
2david_werecat1290.05752012/08/14 02:09:140B / 84B / 40B

REBOL _

RankUserSizeTimeDateStatistics
1clock400.04122012/08/02 08:15:130B / 23B / 13B

AWK _

RankUserSizeTimeDateStatistics
1nn260.01072012/08/11 20:22:120B / 4B / 18B
2yamaya260.01082012/08/12 03:00:380B / 3B / 19B
3clock280.01362012/08/12 02:25:160B / 5B / 21B

sed _

RankUserSizeTimeDateStatistics
1clock250.01092012/08/02 07:54:130B / 5B / 19B
2tails250.01572012/08/02 21:04:200B / 5B / 19B
3teebee250.01102012/08/02 23:31:580B / 5B / 19B
4nn250.01372012/08/03 20:57:570B / 5B / 19B

Bash _

RankUserSizeTimeDateStatistics
1yamaya260.01462012/08/14 14:14:400B / 11B / 12B
2clock310.01352012/08/11 14:47:120B / 8B / 22B

wake _

RankUserSizeTimeDateStatistics
1clock390.00582012/08/10 17:15:520B / 7B / 31B

xgawk _

RankUserSizeTimeDateStatistics
1clock290.01572012/08/11 14:38:530B / 6B / 21B

Whitespace _

RankUserSizeTimeDateStatistics
1%202250.09632016/07/23 15:25:260B / 0B / 0B

GolfScript _

RankUserSizeTimeDateStatistics
1tails290.18762012/08/10 21:16:070B / 6B / 23B

FlogScript _

RankUserSizeTimeDateStatistics
1clock150.04662012/08/02 15:16:490B / 2B / 13B

Vim _

RankUserSizeTimeDateStatistics
1clock240.23352012/08/14 15:50:120B / 9B / 11B
2nn260.01432012/08/11 23:33:410B / 9B / 14B

Groovy _

RankUserSizeTimeDateStatistics
1clock491.09002012/08/03 14:25:110B / 31B / 18B
2nn490.99632012/08/11 23:02:280B / 32B / 17B

Language Ranking_

RankLangUserSizeScore
1FlogScriptclock1510000
2Vimclock246250
3sedclock256000
4AWKnn265769
5Bashyamaya265769
6GolfScripttails295172
7xgawkclock295172
8Rubyclock305000
9Perltails314838
10wakeclock393846
11REBOLclock403750
12JavaScriptclock413658
13Kteebee413658
14Luaclock453333
15Pythonclock483125
16Groovyclock493061
17JI., S.503000
18PHPclock503000
19Schemekaki592542
20Iopooq622419
21Tclclock692173
22SNOBOLclock702142
23Haskellhenkma742027
24Kiteclock742027
25Iconclock811851
26Cdavid_werecat (Y.OHNO)1051428
27C#Hendrik1201250
28Whitespace%20225666

return top