Skip to content

manu156/sed2C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sed2C

A lex-yacc program to convert Sed to C.
Note: Subset of GNU sed grammar is implemented as suitable for C.

Instructions

compile using makefile:

$make

This will create executable "app" which can be used to compile Sed-scripts to C.
"app" takes two arguments, input sed file(file which is to be converted to C), and output filename.

Example:

$./app input.sed output.c
$gcc output.c
$./a.out inputFile > outputFile

flag -n can be used to suppress output after each cycle. Example:

$./app tests/dict1.sed out.c
$gcc output.c
$./a.out tests/dict1.in -n
>bob
>mon
>non
>pop
>sos
>tot
>wow

dict.in is a copy of "/usr/share/dict/words"
output produced by sed:

$sed -n '/^\(.\)o\1$/p' /usr/share/dict/words
>bob
>mon
>non
>pop
>sos
>tot
>wow

Test Files

test.sh can be used to test all sed scripts in /tests/
(updates filenames in tests/ should also be made in test.sh)
/tests/ contains test files in following format:
file.sed : sed file to be tested
file.in : input file for sed
file.out : expected output(output of sed)
Testing(sample):

$./test.sh
>Testing against tests/dict1.in
>TEST OK!
>Enter a to abort, anything else to continue:

test.sh converts file.sed to C, compiles it and executes it with file.in as input. Output is compared with expected file.out(sed output) using diff command.
Test result will be printed for each sed file.
(test-files will be removed automatically after tests)

Note: See Documentation.md for details about implementation details and commands implemented.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published