Added flex
This commit is contained in:
parent
242871916f
commit
52b917ce0c
24
flex/aaaaaaaa.y
Normal file
24
flex/aaaaaaaa.y
Normal file
@ -0,0 +1,24 @@
|
||||
/* @BAKE
|
||||
bison --header=a.tab.h -o a.tab.c $@
|
||||
g++ a.tab.c -o a
|
||||
./a
|
||||
@STOP
|
||||
*/
|
||||
%code requires {
|
||||
#include <iostream>
|
||||
void yyerror(...) { ; }
|
||||
}
|
||||
%union {
|
||||
std::string * strval;
|
||||
}
|
||||
%{
|
||||
int yylex() {
|
||||
yylval.strval = new std::string("There are only two hard problems in CS: cache invalidation, nameing things, and off-by-one errors.");
|
||||
return STRING;
|
||||
}
|
||||
%}
|
||||
%token STRING
|
||||
%%
|
||||
string: STRING { std::cout << *(yylval.strval) << std::endl; }
|
||||
%%
|
||||
signed main() { yyparse(); }
|
10
flex/flex_patter_vs_state/Bakefile
Normal file
10
flex/flex_patter_vs_state/Bakefile
Normal file
@ -0,0 +1,10 @@
|
||||
@BAKE
|
||||
flex -o pattern.yy.c pattern.l
|
||||
flex -o state.yy.c state.l
|
||||
gcc -o pattern.out pattern.yy.c -lfl -g
|
||||
gcc -o state.out state.yy.c -lfl -g
|
||||
python -c '''print("/*", "".join([ "a" for i in range(0,1000000)]), "*/")''' | valgrind --tool=massif --massif-out-file=massif.out.pattern ./pattern.out
|
||||
python -c '''print("/*", "".join([ "a" for i in range(0,1000000)]), "*/")''' | valgrind --tool=massif --massif-out-file=massif.out.state ./state.out
|
||||
ms_print massif.out.pattern
|
||||
ms_print massif.out.state
|
||||
@STOP
|
135
flex/flex_patter_vs_state/massif.out.pattern
Normal file
135
flex/flex_patter_vs_state/massif.out.pattern
Normal file
@ -0,0 +1,135 @@
|
||||
desc: --massif-out-file=massif.out.pattern
|
||||
cmd: ./pattern.out
|
||||
time_unit: i
|
||||
#-----------
|
||||
snapshot=0
|
||||
#-----------
|
||||
time=0
|
||||
mem_heap_B=0
|
||||
mem_heap_extra_B=0
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=1
|
||||
#-----------
|
||||
time=178535
|
||||
mem_heap_B=8
|
||||
mem_heap_extra_B=16
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=2
|
||||
#-----------
|
||||
time=178627
|
||||
mem_heap_B=72
|
||||
mem_heap_extra_B=24
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=3
|
||||
#-----------
|
||||
time=178684
|
||||
mem_heap_B=16458
|
||||
mem_heap_extra_B=46
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=4
|
||||
#-----------
|
||||
time=179417
|
||||
mem_heap_B=20554
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=5
|
||||
#-----------
|
||||
time=2450242
|
||||
mem_heap_B=36938
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=6
|
||||
#-----------
|
||||
time=7769087
|
||||
mem_heap_B=69706
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=7
|
||||
#-----------
|
||||
time=27548940
|
||||
mem_heap_B=135242
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=8
|
||||
#-----------
|
||||
time=103677625
|
||||
mem_heap_B=266314
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=9
|
||||
#-----------
|
||||
time=402211238
|
||||
mem_heap_B=528458
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=detailed
|
||||
n2: 528458 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
|
||||
n1: 524290 0x10B046: yyrealloc (pattern.yy.c:1745)
|
||||
n1: 524290 0x109AAE: yy_get_next_buffer (pattern.yy.c:960)
|
||||
n1: 524290 0x10977F: yylex (pattern.yy.c:822)
|
||||
n0: 524290 0x109234: main (in /home/anon/Swap/tests/flex_patter_vs_state/pattern.out)
|
||||
n0: 4168 in 2 places, all below massif's threshold (1.00%)
|
||||
#-----------
|
||||
snapshot=10
|
||||
#-----------
|
||||
time=1584383763
|
||||
mem_heap_B=1052746
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=11
|
||||
#-----------
|
||||
time=5796516138
|
||||
mem_heap_B=1053770
|
||||
mem_heap_extra_B=62
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=12
|
||||
#-----------
|
||||
time=5796520196
|
||||
mem_heap_B=1053770
|
||||
mem_heap_extra_B=62
|
||||
mem_stacks_B=0
|
||||
heap_tree=peak
|
||||
n2: 1053770 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
|
||||
n1: 1048578 0x10B046: yyrealloc (pattern.yy.c:1745)
|
||||
n1: 1048578 0x109AAE: yy_get_next_buffer (pattern.yy.c:960)
|
||||
n1: 1048578 0x10977F: yylex (pattern.yy.c:822)
|
||||
n0: 1048578 0x109234: main (in /home/anon/Swap/tests/flex_patter_vs_state/pattern.out)
|
||||
n0: 5192 in 2 places, all below massif's threshold (1.00%)
|
||||
#-----------
|
||||
snapshot=13
|
||||
#-----------
|
||||
time=5796520196
|
||||
mem_heap_B=1049674
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=14
|
||||
#-----------
|
||||
time=5796520230
|
||||
mem_heap_B=1048650
|
||||
mem_heap_extra_B=46
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
95
flex/flex_patter_vs_state/massif.out.state
Normal file
95
flex/flex_patter_vs_state/massif.out.state
Normal file
@ -0,0 +1,95 @@
|
||||
desc: --massif-out-file=massif.out.state
|
||||
cmd: ./state.out
|
||||
time_unit: i
|
||||
#-----------
|
||||
snapshot=0
|
||||
#-----------
|
||||
time=0
|
||||
mem_heap_B=0
|
||||
mem_heap_extra_B=0
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=1
|
||||
#-----------
|
||||
time=178536
|
||||
mem_heap_B=8
|
||||
mem_heap_extra_B=16
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=2
|
||||
#-----------
|
||||
time=178628
|
||||
mem_heap_B=72
|
||||
mem_heap_extra_B=24
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=3
|
||||
#-----------
|
||||
time=178685
|
||||
mem_heap_B=16458
|
||||
mem_heap_extra_B=46
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=4
|
||||
#-----------
|
||||
time=179418
|
||||
mem_heap_B=20554
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=5
|
||||
#-----------
|
||||
time=94248676
|
||||
mem_heap_B=21578
|
||||
mem_heap_extra_B=62
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=6
|
||||
#-----------
|
||||
time=94252737
|
||||
mem_heap_B=21578
|
||||
mem_heap_extra_B=62
|
||||
mem_stacks_B=0
|
||||
heap_tree=peak
|
||||
n2: 21578 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
|
||||
n2: 16458 0x10B03B: yyalloc (state.yy.c:1747)
|
||||
n1: 16386 0x10A699: yy_create_buffer (state.yy.c:1294)
|
||||
n1: 16386 0x1093ED: yylex (state.yy.c:676)
|
||||
n0: 16386 0x109234: main (in /home/anon/Swap/tests/flex_patter_vs_state/state.out)
|
||||
n0: 72 in 2 places, all below massif's threshold (1.00%)
|
||||
n1: 5120 0x48DB95C: _IO_file_doallocate (filedoalloc.c:101)
|
||||
n1: 5120 0x48EA958: _IO_doallocbuf (genops.c:347)
|
||||
n2: 5120 0x48EA958: _IO_doallocbuf (genops.c:342)
|
||||
n1: 4096 0x48E98BB: _IO_file_xsgetn (fileops.c:1288)
|
||||
n1: 4096 0x48DCA4E: fread (iofread.c:38)
|
||||
n1: 4096 0x109CDB: yy_get_next_buffer (state.yy.c:997)
|
||||
n1: 4096 0x10979D: yylex (state.yy.c:837)
|
||||
n0: 4096 0x109234: main (in /home/anon/Swap/tests/flex_patter_vs_state/state.out)
|
||||
n1: 1024 0x48E8A77: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:745)
|
||||
n1: 1024 0x48E95C6: _IO_new_file_xsputn (fileops.c:1244)
|
||||
n1: 1024 0x48E95C6: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1197)
|
||||
n1: 1024 0x48DCF71: fwrite (iofwrite.c:39)
|
||||
n1: 1024 0x10963E: yylex (state.l:9)
|
||||
n0: 1024 0x109234: main (in /home/anon/Swap/tests/flex_patter_vs_state/state.out)
|
||||
#-----------
|
||||
snapshot=7
|
||||
#-----------
|
||||
time=94252737
|
||||
mem_heap_B=17482
|
||||
mem_heap_extra_B=54
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
||||
#-----------
|
||||
snapshot=8
|
||||
#-----------
|
||||
time=94252771
|
||||
mem_heap_B=16458
|
||||
mem_heap_extra_B=46
|
||||
mem_stacks_B=0
|
||||
heap_tree=empty
|
4
flex/flex_patter_vs_state/pattern.l
Normal file
4
flex/flex_patter_vs_state/pattern.l
Normal file
@ -0,0 +1,4 @@
|
||||
%option noyywrap
|
||||
%%
|
||||
<INITIAL>\/\*([^*]|\*+[^/*])*\*+\/ { ; }
|
||||
%%
|
1758
flex/flex_patter_vs_state/pattern.yy.c
Normal file
1758
flex/flex_patter_vs_state/pattern.yy.c
Normal file
File diff suppressed because it is too large
Load Diff
9
flex/flex_patter_vs_state/state.l
Normal file
9
flex/flex_patter_vs_state/state.l
Normal file
@ -0,0 +1,9 @@
|
||||
%option noyywrap
|
||||
%x COMMENT
|
||||
%%
|
||||
<INITIAL>\/\* { BEGIN COMMENT; }
|
||||
<COMMENT>{
|
||||
. { ; }
|
||||
\*\/ { BEGIN INITIAL; }
|
||||
}
|
||||
%%
|
1773
flex/flex_patter_vs_state/state.yy.c
Normal file
1773
flex/flex_patter_vs_state/state.yy.c
Normal file
File diff suppressed because it is too large
Load Diff
11
flex/hack.l
Normal file
11
flex/hack.l
Normal file
@ -0,0 +1,11 @@
|
||||
/* @BAKE
|
||||
flex -o edge.yy.c $@
|
||||
gcc edge.yy.c -o edge.out -lfl
|
||||
./edge.out
|
||||
@STOP
|
||||
*/
|
||||
%x HILL
|
||||
%%
|
||||
{ puts("Let me help you, Sisyphus!"); goto top; }
|
||||
<HILL>. { top: puts("There you go!"); exit(0); }
|
||||
%%
|
15
flex/hw.l
Normal file
15
flex/hw.l
Normal file
@ -0,0 +1,15 @@
|
||||
%{
|
||||
#include <stdio.h>
|
||||
%}
|
||||
|
||||
%%
|
||||
hello printf("World!\n");
|
||||
%{
|
||||
int i;
|
||||
%}
|
||||
%%
|
||||
|
||||
int main() {
|
||||
yylex();
|
||||
return 0;
|
||||
}
|
3
flex/sections.l
Normal file
3
flex/sections.l
Normal file
@ -0,0 +1,3 @@
|
||||
%%
|
||||
<.>
|
||||
%%
|
Loading…
x
Reference in New Issue
Block a user