Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#(f?)lex (39)

(f?)lex (39)

File inc.l:

%%
[0-9]+ printf("%d",atoi(yytext)+1);

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

#(f?)lex (39)

File inc.l:

%%
[0-9]+ printf("%d",atoi(yytext)+1);

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

(f?)lex (39)

File inc.l:

%%
[0-9]+ printf("%d",atoi(yytext)+1);

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

deleted 31 characters in body
Source Link
user19214
user19214

#(f?)lex (4139)

File inc.l (no trailing new line):

%%
[0-9]+ printf("%d",atoi(yytext)+1);
%%

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

#(f?)lex (41)

File inc.l (no trailing new line):

%%
[0-9]+ printf("%d",atoi(yytext)+1);
%%

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

#(f?)lex (39)

File inc.l:

%%
[0-9]+ printf("%d",atoi(yytext)+1);

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

deleted 98 characters in body
Source Link
user19214
user19214

#(f?)lex (41)

Not a candidate for winning this golfing, but I think (f?)lex deserves some attention... ;-)

File inc.l (no trailing new line):

%%
[0-9]+ printf("%d",atoi(yytext)+1);
%%

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

#(f?)lex (41)

Not a candidate for winning this golfing, but I think (f?)lex deserves some attention... ;-)

File inc.l (no trailing new line):

%%
[0-9]+ printf("%d",atoi(yytext)+1);
%%

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

#(f?)lex (41)

File inc.l (no trailing new line):

%%
[0-9]+ printf("%d",atoi(yytext)+1);
%%

Compile:

$ flex inc.l
$ gcc lex.yy.c -o inc -lfl

Run:

$ echo 'teststring134this 123test string54 100' | ./inc
teststring135this 124test string55 101
$ i='(-: 2 empty bottles of beer :-)'
$ tty=$(tty)
$ for n in {2..5} ; do i=$(./inc<<<$i|tee $tty) ; done
(-: 3 empty bottles of beer :-)
(-: 4 empty bottles of beer :-)
(-: 5 empty bottles of beer :-)
(-: 6 empty bottles of beer :-)

I did not test this with the original lex. Comments are welcome.

relying on "default rule" to rule them all!
Source Link
user19214
user19214
Loading
[^0-9] --> .
Source Link
user19214
user19214
Loading
Source Link
user19214
user19214
Loading

AltStyle によって変換されたページ (->オリジナル) /