SlideShare a Scribd company logo
1 of 21
Download to read offline
An OCaml newbie meets Camlp4
parser
An OCaml newbie meets Camlp4
parser
An OCaml newbie meets Camlp4
parser
An OCaml newbie meets Camlp4
parser
An OCaml newbie meets Camlp4
parser
Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
Why use Camlp4 parser?Why use Camlp4 parser?Why use Camlp4 parser?Why use Camlp4 parser?Why use Camlp4 parser?
☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?
☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.
What is VeriFast verifier? #1What is VeriFast verifier? #1What is VeriFast verifier? #1What is VeriFast verifier? #1What is VeriFast verifier? #1
☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast
☆ A verifier for single-threaded and multi-
threaded C and Java language programs
annotated with preconditions and
postconditions written in separation logic.
☆ A verifier for single-threaded and multi-
threaded C and Java language programs
annotated with preconditions and
postconditions written in separation logic.
☆ A verifier for single-threaded and multi-
threaded C and Java language programs
annotated with preconditions and
postconditions written in separation logic.
☆ A verifier for single-threaded and multi-
threaded C and Java language programs
annotated with preconditions and
postconditions written in separation logic.
☆ A verifier for single-threaded and multi-
threaded C and Java language programs
annotated with preconditions and
postconditions written in separation logic.
☆ VeriFast avoids illegal memory accesses such
like buffer overflow.
☆ VeriFast avoids illegal memory accesses such
like buffer overflow.
☆ VeriFast avoids illegal memory accesses such
like buffer overflow.
☆ VeriFast avoids illegal memory accesses such
like buffer overflow.
☆ VeriFast avoids illegal memory accesses such
like buffer overflow.
☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.
What is VeriFast verifier? #2What is VeriFast verifier? #2What is VeriFast verifier? #2What is VeriFast verifier? #2What is VeriFast verifier? #2
What is VeriFast verifier? #3What is VeriFast verifier? #3What is VeriFast verifier? #3What is VeriFast verifier? #3What is VeriFast verifier? #3
VeriFast has own C language parserVeriFast has own C language parserVeriFast has own C language parserVeriFast has own C language parserVeriFast has own C language parser
let rec parse_decls ?inGhostHeader =
if match inGhostHeader with None -> false | Some b -> b then
parse_pure_decls
else
parse_decls_core
and
parse_decls_core = parser
[< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/");
ds' = parse_decls_core >] -> ds @ ds'
| [< _ = opt (parser [< '(_, Kwd "public") >] -> ());
abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false);
final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] ->
ExtensibleClass);
ds = begin parser
let rec parse_decls ?inGhostHeader =
if match inGhostHeader with None -> false | Some b -> b then
parse_pure_decls
else
parse_decls_core
and
parse_decls_core = parser
[< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/");
ds' = parse_decls_core >] -> ds @ ds'
| [< _ = opt (parser [< '(_, Kwd "public") >] -> ());
abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false);
final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] ->
ExtensibleClass);
ds = begin parser
let rec parse_decls ?inGhostHeader =
if match inGhostHeader with None -> false | Some b -> b then
parse_pure_decls
else
parse_decls_core
and
parse_decls_core = parser
[< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/");
ds' = parse_decls_core >] -> ds @ ds'
| [< _ = opt (parser [< '(_, Kwd "public") >] -> ());
abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false);
final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] ->
ExtensibleClass);
ds = begin parser
let rec parse_decls ?inGhostHeader =
if match inGhostHeader with None -> false | Some b -> b then
parse_pure_decls
else
parse_decls_core
and
parse_decls_core = parser
[< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/");
ds' = parse_decls_core >] -> ds @ ds'
| [< _ = opt (parser [< '(_, Kwd "public") >] -> ());
abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false);
final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] ->
ExtensibleClass);
ds = begin parser
let rec parse_decls ?inGhostHeader =
if match inGhostHeader with None -> false | Some b -> b then
parse_pure_decls
else
parse_decls_core
and
parse_decls_core = parser
[< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/");
ds' = parse_decls_core >] -> ds @ ds'
| [< _ = opt (parser [< '(_, Kwd "public") >] -> ());
abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false);
final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] ->
ExtensibleClass);
ds = begin parser
Why modify VeriFast parser? #1Why modify VeriFast parser? #1Why modify VeriFast parser? #1Why modify VeriFast parser? #1Why modify VeriFast parser? #1
Why modify VeriFast parser? #2Why modify VeriFast parser? #2Why modify VeriFast parser? #2Why modify VeriFast parser? #2Why modify VeriFast parser? #2
☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.
☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.
☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.
☆ They may have some semantic gaps, which
cause miss verification.
☆ They may have some semantic gaps, which
cause miss verification.
☆ They may have some semantic gaps, which
cause miss verification.
☆ They may have some semantic gaps, which
cause miss verification.
☆ They may have some semantic gaps, which
cause miss verification.
☆ Because VeriFast's parser is a subset of C99
parser.
☆ Because VeriFast's parser is a subset of C99
parser.
☆ Because VeriFast's parser is a subset of C99
parser.
☆ Because VeriFast's parser is a subset of C99
parser.
☆ Because VeriFast's parser is a subset of C99
parser.
What is a near-term goal?What is a near-term goal?What is a near-term goal?What is a near-term goal?What is a near-term goal?
☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.
☆ Let's verify "kern/subr_optstr.c" file in NetBSD
kernel:
☆ Let's verify "kern/subr_optstr.c" file in NetBSD
kernel:
☆ Let's verify "kern/subr_optstr.c" file in NetBSD
kernel:
☆ Let's verify "kern/subr_optstr.c" file in NetBSD
kernel:
☆ Let's verify "kern/subr_optstr.c" file in NetBSD
kernel:
$ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools
$ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC
$ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I
sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c
$ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools
$ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC
$ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I
sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c
$ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools
$ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC
$ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I
sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c
$ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools
$ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC
$ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I
sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c
$ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools
$ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC
$ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I
sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c
☆ The kernel code is found at following:☆ The kernel code is found at following:☆ The kernel code is found at following:☆ The kernel code is found at following:☆ The kernel code is found at following:
☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src
Original verifierOriginal verifierOriginal verifierOriginal verifierOriginal verifier
Modified verifierModified verifierModified verifierModified verifierModified verifier
My patches for VeriFast's parserMy patches for VeriFast's parserMy patches for VeriFast's parserMy patches for VeriFast's parserMy patches for VeriFast's parser
* Parse semicolon without any declarations #121
https://github.com/verifast/verifast/pull/121
* Allow hardtab in string literals #120
https://github.com/verifast/verifast/pull/120
* Ignore inline keyword at static function declaration #119
https://github.com/verifast/verifast/pull/119
* Support operators in macros / Add -D option #116
https://github.com/verifast/verifast/pull/116
* Parse semicolon without any declarations #121
https://github.com/verifast/verifast/pull/121
* Allow hardtab in string literals #120
https://github.com/verifast/verifast/pull/120
* Ignore inline keyword at static function declaration #119
https://github.com/verifast/verifast/pull/119
* Support operators in macros / Add -D option #116
https://github.com/verifast/verifast/pull/116
* Parse semicolon without any declarations #121
https://github.com/verifast/verifast/pull/121
* Allow hardtab in string literals #120
https://github.com/verifast/verifast/pull/120
* Ignore inline keyword at static function declaration #119
https://github.com/verifast/verifast/pull/119
* Support operators in macros / Add -D option #116
https://github.com/verifast/verifast/pull/116
* Parse semicolon without any declarations #121
https://github.com/verifast/verifast/pull/121
* Allow hardtab in string literals #120
https://github.com/verifast/verifast/pull/120
* Ignore inline keyword at static function declaration #119
https://github.com/verifast/verifast/pull/119
* Support operators in macros / Add -D option #116
https://github.com/verifast/verifast/pull/116
* Parse semicolon without any declarations #121
https://github.com/verifast/verifast/pull/121
* Allow hardtab in string literals #120
https://github.com/verifast/verifast/pull/120
* Ignore inline keyword at static function declaration #119
https://github.com/verifast/verifast/pull/119
* Support operators in macros / Add -D option #116
https://github.com/verifast/verifast/pull/116
Knowledge to debug parser #1-1Knowledge to debug parser #1-1Knowledge to debug parser #1-1Knowledge to debug parser #1-1Knowledge to debug parser #1-1
☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.
$ git diff
diff --git a/src/vfconsole.ml b/src/vfconsole.ml
index 8846dcb5..9204c2a4 100644
--- a/src/vfconsole.ml
+++ b/src/vfconsole.ml
@@ -23,7 +23,6 @@ let _ =
Java_frontend_bridge.unload();
with
PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1
- | ParseException (l, msg) -> print_msg l ("Parse error" ^ ...
| CompilationError(msg) -> print_endline (msg); exit 1
| StaticError (l, msg, url) -> print_msg l msg; exit 1
| SymbolicExecutionError (ctxts, l, msg, url) ->
$ git diff
diff --git a/src/vfconsole.ml b/src/vfconsole.ml
index 8846dcb5..9204c2a4 100644
--- a/src/vfconsole.ml
+++ b/src/vfconsole.ml
@@ -23,7 +23,6 @@ let _ =
Java_frontend_bridge.unload();
with
PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1
- | ParseException (l, msg) -> print_msg l ("Parse error" ^ ...
| CompilationError(msg) -> print_endline (msg); exit 1
| StaticError (l, msg, url) -> print_msg l msg; exit 1
| SymbolicExecutionError (ctxts, l, msg, url) ->
$ git diff
diff --git a/src/vfconsole.ml b/src/vfconsole.ml
index 8846dcb5..9204c2a4 100644
--- a/src/vfconsole.ml
+++ b/src/vfconsole.ml
@@ -23,7 +23,6 @@ let _ =
Java_frontend_bridge.unload();
with
PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1
- | ParseException (l, msg) -> print_msg l ("Parse error" ^ ...
| CompilationError(msg) -> print_endline (msg); exit 1
| StaticError (l, msg, url) -> print_msg l msg; exit 1
| SymbolicExecutionError (ctxts, l, msg, url) ->
$ git diff
diff --git a/src/vfconsole.ml b/src/vfconsole.ml
index 8846dcb5..9204c2a4 100644
--- a/src/vfconsole.ml
+++ b/src/vfconsole.ml
@@ -23,7 +23,6 @@ let _ =
Java_frontend_bridge.unload();
with
PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1
- | ParseException (l, msg) -> print_msg l ("Parse error" ^ ...
| CompilationError(msg) -> print_endline (msg); exit 1
| StaticError (l, msg, url) -> print_msg l msg; exit 1
| SymbolicExecutionError (ctxts, l, msg, url) ->
$ git diff
diff --git a/src/vfconsole.ml b/src/vfconsole.ml
index 8846dcb5..9204c2a4 100644
--- a/src/vfconsole.ml
+++ b/src/vfconsole.ml
@@ -23,7 +23,6 @@ let _ =
Java_frontend_bridge.unload();
with
PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1
- | ParseException (l, msg) -> print_msg l ("Parse error" ^ ...
| CompilationError(msg) -> print_endline (msg); exit 1
| StaticError (l, msg, url) -> print_msg l msg; exit 1
| SymbolicExecutionError (ctxts, l, msg, url) ->
Knowledge to debug parser #1-2Knowledge to debug parser #1-2Knowledge to debug parser #1-2Knowledge to debug parser #1-2Knowledge to debug parser #1-2
$ cat tab_in_printf.c
#include <stdio.h>
int main() {
printf("Use hard tabn");
return 0;
}
$ OCAMLRUNPARAM=b verifast -c tab_in_printf.c
tab_in_printf.c
Fatal error: exception Lexer.ParseException(_, "")
Raised at file "parser.ml", line 1627, characters 26-61
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
Called from file "verifast.ml", line 2922, characters 17-1023
Called from file "verifast.ml", line 3130, characters 18-460
$ cat tab_in_printf.c
#include <stdio.h>
int main() {
printf("Use hard tabn");
return 0;
}
$ OCAMLRUNPARAM=b verifast -c tab_in_printf.c
tab_in_printf.c
Fatal error: exception Lexer.ParseException(_, "")
Raised at file "parser.ml", line 1627, characters 26-61
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
Called from file "verifast.ml", line 2922, characters 17-1023
Called from file "verifast.ml", line 3130, characters 18-460
$ cat tab_in_printf.c
#include <stdio.h>
int main() {
printf("Use hard tabn");
return 0;
}
$ OCAMLRUNPARAM=b verifast -c tab_in_printf.c
tab_in_printf.c
Fatal error: exception Lexer.ParseException(_, "")
Raised at file "parser.ml", line 1627, characters 26-61
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
Called from file "verifast.ml", line 2922, characters 17-1023
Called from file "verifast.ml", line 3130, characters 18-460
$ cat tab_in_printf.c
#include <stdio.h>
int main() {
printf("Use hard tabn");
return 0;
}
$ OCAMLRUNPARAM=b verifast -c tab_in_printf.c
tab_in_printf.c
Fatal error: exception Lexer.ParseException(_, "")
Raised at file "parser.ml", line 1627, characters 26-61
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
Called from file "verifast.ml", line 2922, characters 17-1023
Called from file "verifast.ml", line 3130, characters 18-460
$ cat tab_in_printf.c
#include <stdio.h>
int main() {
printf("Use hard tabn");
return 0;
}
$ OCAMLRUNPARAM=b verifast -c tab_in_printf.c
tab_in_printf.c
Fatal error: exception Lexer.ParseException(_, "")
Raised at file "parser.ml", line 1627, characters 26-61
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
Called from file "verifast.ml", line 2922, characters 17-1023
Called from file "verifast.ml", line 3130, characters 18-460
Knowledge to debug parser #2-1Knowledge to debug parser #2-1Knowledge to debug parser #2-1Knowledge to debug parser #2-1Knowledge to debug parser #2-1
☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.
let rec print_tokens_list tokens =
match tokens with
[(_, tok)] -> Printf.printf "%sn" (string_of_token tok)
| (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok);
print_tokens_list xs
| [] -> Printf.printf "n"
let rec print_tokens_stream tokens =
Printf.printf "[n";
Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok))
tokens;
Printf.printf "]n"
let rec print_tokens_list tokens =
match tokens with
[(_, tok)] -> Printf.printf "%sn" (string_of_token tok)
| (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok);
print_tokens_list xs
| [] -> Printf.printf "n"
let rec print_tokens_stream tokens =
Printf.printf "[n";
Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok))
tokens;
Printf.printf "]n"
let rec print_tokens_list tokens =
match tokens with
[(_, tok)] -> Printf.printf "%sn" (string_of_token tok)
| (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok);
print_tokens_list xs
| [] -> Printf.printf "n"
let rec print_tokens_stream tokens =
Printf.printf "[n";
Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok))
tokens;
Printf.printf "]n"
let rec print_tokens_list tokens =
match tokens with
[(_, tok)] -> Printf.printf "%sn" (string_of_token tok)
| (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok);
print_tokens_list xs
| [] -> Printf.printf "n"
let rec print_tokens_stream tokens =
Printf.printf "[n";
Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok))
tokens;
Printf.printf "]n"
let rec print_tokens_list tokens =
match tokens with
[(_, tok)] -> Printf.printf "%sn" (string_of_token tok)
| (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok);
print_tokens_list xs
| [] -> Printf.printf "n"
let rec print_tokens_stream tokens =
Printf.printf "[n";
Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok))
tokens;
Printf.printf "]n"
Knowledge to debug parser #3-1Knowledge to debug parser #3-1Knowledge to debug parser #3-1Knowledge to debug parser #3-1Knowledge to debug parser #3-1
☆ Exception "Stream.Error" has a string
parameter specified by "??".
☆ Exception "Stream.Error" has a string
parameter specified by "??".
☆ Exception "Stream.Error" has a string
parameter specified by "??".
☆ Exception "Stream.Error" has a string
parameter specified by "??".
☆ Exception "Stream.Error" has a string
parameter specified by "??".
$ wc -l src/parser.ml
1801 src/parser.ml
$ vi src/parser.ml
$ wc -l src/parser.ml
1801 src/parser.ml
$ vi src/parser.ml
$ wc -l src/parser.ml
1801 src/parser.ml
$ vi src/parser.ml
$ wc -l src/parser.ml
1801 src/parser.ml
$ vi src/parser.ml
$ wc -l src/parser.ml
1801 src/parser.ml
$ vi src/parser.ml
let parse_c_file = parser
[< (headers, _) = parse_include_directives ignore_eol verbose
enforceAnnotations dataModel;
ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false;
_ = Stream.empty ?? "Stream.empty expected" (* <= *) >]
-> (headers, [PackageDecl(dummy_loc,"",[],ds)])
in
parse_c_file token_stream
let parse_c_file = parser
[< (headers, _) = parse_include_directives ignore_eol verbose
enforceAnnotations dataModel;
ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false;
_ = Stream.empty ?? "Stream.empty expected" (* <= *) >]
-> (headers, [PackageDecl(dummy_loc,"",[],ds)])
in
parse_c_file token_stream
let parse_c_file = parser
[< (headers, _) = parse_include_directives ignore_eol verbose
enforceAnnotations dataModel;
ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false;
_ = Stream.empty ?? "Stream.empty expected" (* <= *) >]
-> (headers, [PackageDecl(dummy_loc,"",[],ds)])
in
parse_c_file token_stream
let parse_c_file = parser
[< (headers, _) = parse_include_directives ignore_eol verbose
enforceAnnotations dataModel;
ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false;
_ = Stream.empty ?? "Stream.empty expected" (* <= *) >]
-> (headers, [PackageDecl(dummy_loc,"",[],ds)])
in
parse_c_file token_stream
let parse_c_file = parser
[< (headers, _) = parse_include_directives ignore_eol verbose
enforceAnnotations dataModel;
ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false;
_ = Stream.empty ?? "Stream.empty expected" (* <= *) >]
-> (headers, [PackageDecl(dummy_loc,"",[],ds)])
in
parse_c_file token_stream
Knowledge to debug parser #3-2Knowledge to debug parser #3-2Knowledge to debug parser #3-2Knowledge to debug parser #3-2Knowledge to debug parser #3-2
$ cat main.c
;
#include <stdio.h>
$ OCAMLRUNPARAM=b verifast -c main.c
main.c
Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <=
Raised at file "parser.ml", line 1629, characters 6-312
Called from file "parser.ml", line 1634, characters 6-31
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
$ cat main.c
;
#include <stdio.h>
$ OCAMLRUNPARAM=b verifast -c main.c
main.c
Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <=
Raised at file "parser.ml", line 1629, characters 6-312
Called from file "parser.ml", line 1634, characters 6-31
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
$ cat main.c
;
#include <stdio.h>
$ OCAMLRUNPARAM=b verifast -c main.c
main.c
Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <=
Raised at file "parser.ml", line 1629, characters 6-312
Called from file "parser.ml", line 1634, characters 6-31
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
$ cat main.c
;
#include <stdio.h>
$ OCAMLRUNPARAM=b verifast -c main.c
main.c
Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <=
Raised at file "parser.ml", line 1629, characters 6-312
Called from file "parser.ml", line 1634, characters 6-31
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
$ cat main.c
;
#include <stdio.h>
$ OCAMLRUNPARAM=b verifast -c main.c
main.c
Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <=
Raised at file "parser.ml", line 1629, characters 6-312
Called from file "parser.ml", line 1634, characters 6-31
Called from file "verifast.ml", line 2966, characters 12-185
Called from file "verifast1.ml", line 470, characters 6-13
Called from file "util.ml" (inlined), line 109, characters 15-18
Let's join the VeriFast project!Let's join the VeriFast project!Let's join the VeriFast project!Let's join the VeriFast project!Let's join the VeriFast project!
☆ To verify C language on real world.☆ To verify C language on real world.☆ To verify C language on real world.☆ To verify C language on real world.☆ To verify C language on real world.
☆ To get better parser.☆ To get better parser.☆ To get better parser.☆ To get better parser.☆ To get better parser.
Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回
☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.
☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/
☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:
ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C,
FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast,
Why3, boogie, cogent, corral, seL4, vcc, etc.
ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C,
FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast,
Why3, boogie, cogent, corral, seL4, vcc, etc.
ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C,
FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast,
Why3, boogie, cogent, corral, seL4, vcc, etc.
ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C,
FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast,
Why3, boogie, cogent, corral, seL4, vcc, etc.
ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C,
FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast,
Why3, boogie, cogent, corral, seL4, vcc, etc.
☆ We are calling for presentation.☆ We are calling for presentation.☆ We are calling for presentation.☆ We are calling for presentation.☆ We are calling for presentation.
Ads: Functional Ikamusume bookAds: Functional Ikamusume bookAds: Functional Ikamusume bookAds: Functional Ikamusume bookAds: Functional Ikamusume book
☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.
http://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.html
☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!
☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.
☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.
☆ Please read following about CFA:☆ Please read following about CFA:☆ Please read following about CFA:☆ Please read following about CFA:☆ Please read following about CFA:
☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke
License of photosLicense of photosLicense of photosLicense of photosLicense of photos
* Creative Commons BBB | Flickr
https://www.flickr.com/photos/steren/2732488224/
Copyright: Steren Giannini / License: CC BY 2.0
* Smiling Camel | John Campbell | Flickr
https://www.flickr.com/photos/104346167@N06/16765659629/
Copyright: John Campbell / License: Public domain
* ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille |
Flickr
https://www.flickr.com/photos/paille-fr/8070924277/
Copyright: Paille / License: CC BY-SA 2.0
* Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr
https://www.flickr.com/photos/joeflintham/4196385813/
Copyright: Joe Flintham / License: CC BY-SA 2.0
* Creative Commons BBB | Flickr
https://www.flickr.com/photos/steren/2732488224/
Copyright: Steren Giannini / License: CC BY 2.0
* Smiling Camel | John Campbell | Flickr
https://www.flickr.com/photos/104346167@N06/16765659629/
Copyright: John Campbell / License: Public domain
* ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille |
Flickr
https://www.flickr.com/photos/paille-fr/8070924277/
Copyright: Paille / License: CC BY-SA 2.0
* Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr
https://www.flickr.com/photos/joeflintham/4196385813/
Copyright: Joe Flintham / License: CC BY-SA 2.0
* Creative Commons BBB | Flickr
https://www.flickr.com/photos/steren/2732488224/
Copyright: Steren Giannini / License: CC BY 2.0
* Smiling Camel | John Campbell | Flickr
https://www.flickr.com/photos/104346167@N06/16765659629/
Copyright: John Campbell / License: Public domain
* ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille |
Flickr
https://www.flickr.com/photos/paille-fr/8070924277/
Copyright: Paille / License: CC BY-SA 2.0
* Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr
https://www.flickr.com/photos/joeflintham/4196385813/
Copyright: Joe Flintham / License: CC BY-SA 2.0
* Creative Commons BBB | Flickr
https://www.flickr.com/photos/steren/2732488224/
Copyright: Steren Giannini / License: CC BY 2.0
* Smiling Camel | John Campbell | Flickr
https://www.flickr.com/photos/104346167@N06/16765659629/
Copyright: John Campbell / License: Public domain
* ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille |
Flickr
https://www.flickr.com/photos/paille-fr/8070924277/
Copyright: Paille / License: CC BY-SA 2.0
* Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr
https://www.flickr.com/photos/joeflintham/4196385813/
Copyright: Joe Flintham / License: CC BY-SA 2.0
* Creative Commons BBB | Flickr
https://www.flickr.com/photos/steren/2732488224/
Copyright: Steren Giannini / License: CC BY 2.0
* Smiling Camel | John Campbell | Flickr
https://www.flickr.com/photos/104346167@N06/16765659629/
Copyright: John Campbell / License: Public domain
* ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille |
Flickr
https://www.flickr.com/photos/paille-fr/8070924277/
Copyright: Paille / License: CC BY-SA 2.0
* Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr
https://www.flickr.com/photos/joeflintham/4196385813/
Copyright: Joe Flintham / License: CC BY-SA 2.0

More Related Content

What's hot

Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLitecharsbar
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)charsbar
 
Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with MoopsMike Friedman
 
Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016Alena Holligan
 
Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)James Titcumb
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codecharsbar
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)Mike Friedman
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in PerlLaurent Dami
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for DummiesElizabeth Smith
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Nikita Popov
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)James Titcumb
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaPatrick Allaert
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and coPierre Joye
 

What's hot (20)

Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with Moops
 
Kamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load BalancersKamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load Balancers
 
Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016Demystifying Object-Oriented Programming - ZendCon 2016
Demystifying Object-Oriented Programming - ZendCon 2016
 
Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 code
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for Dummies
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 

Similar to An OCaml newbie meets Camlp4 parser

Juggling Chainsaws: Perl and MongoDB
Juggling Chainsaws: Perl and MongoDBJuggling Chainsaws: Perl and MongoDB
Juggling Chainsaws: Perl and MongoDBDavid Golden
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to RakuSimon Proctor
 
Introduction to VeriFast @ Kyoto
Introduction to VeriFast @ KyotoIntroduction to VeriFast @ Kyoto
Introduction to VeriFast @ KyotoKiwamu Okabe
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteBram Vogelaar
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceJesse Vincent
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardSV Ruby on Rails Meetup
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchinaguestcf9240
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CDavid Wheeler
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it2shortplanks
 
Exploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsExploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsMarian Marinov
 
Effective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDEffective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDCODEiD PHP Community
 

Similar to An OCaml newbie meets Camlp4 parser (20)

Juggling Chainsaws: Perl and MongoDB
Juggling Chainsaws: Perl and MongoDBJuggling Chainsaws: Perl and MongoDB
Juggling Chainsaws: Perl and MongoDB
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to Raku
 
Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
Introduction to VeriFast @ Kyoto
Introduction to VeriFast @ KyotoIntroduction to VeriFast @ Kyoto
Introduction to VeriFast @ Kyoto
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning C
 
Data Validation models
Data Validation modelsData Validation models
Data Validation models
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it
 
Exploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsExploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your plugins
 
Effective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDEffective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiD
 

Recently uploaded

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

An OCaml newbie meets Camlp4 parser

  • 1. An OCaml newbie meets Camlp4 parser An OCaml newbie meets Camlp4 parser An OCaml newbie meets Camlp4 parser An OCaml newbie meets Camlp4 parser An OCaml newbie meets Camlp4 parser Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
  • 2. Why use Camlp4 parser?Why use Camlp4 parser?Why use Camlp4 parser?Why use Camlp4 parser?Why use Camlp4 parser? ☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser?☆ Why not use the Menhir as parser? ☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.☆ Because VeriFast verifier uses Camlp4 parser.
  • 3. What is VeriFast verifier? #1What is VeriFast verifier? #1What is VeriFast verifier? #1What is VeriFast verifier? #1What is VeriFast verifier? #1 ☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast☆ https://github.com/verifast/verifast ☆ A verifier for single-threaded and multi- threaded C and Java language programs annotated with preconditions and postconditions written in separation logic. ☆ A verifier for single-threaded and multi- threaded C and Java language programs annotated with preconditions and postconditions written in separation logic. ☆ A verifier for single-threaded and multi- threaded C and Java language programs annotated with preconditions and postconditions written in separation logic. ☆ A verifier for single-threaded and multi- threaded C and Java language programs annotated with preconditions and postconditions written in separation logic. ☆ A verifier for single-threaded and multi- threaded C and Java language programs annotated with preconditions and postconditions written in separation logic. ☆ VeriFast avoids illegal memory accesses such like buffer overflow. ☆ VeriFast avoids illegal memory accesses such like buffer overflow. ☆ VeriFast avoids illegal memory accesses such like buffer overflow. ☆ VeriFast avoids illegal memory accesses such like buffer overflow. ☆ VeriFast avoids illegal memory accesses such like buffer overflow. ☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.☆ VeriFast is written by OCaml.
  • 4. What is VeriFast verifier? #2What is VeriFast verifier? #2What is VeriFast verifier? #2What is VeriFast verifier? #2What is VeriFast verifier? #2
  • 5. What is VeriFast verifier? #3What is VeriFast verifier? #3What is VeriFast verifier? #3What is VeriFast verifier? #3What is VeriFast verifier? #3
  • 6. VeriFast has own C language parserVeriFast has own C language parserVeriFast has own C language parserVeriFast has own C language parserVeriFast has own C language parser let rec parse_decls ?inGhostHeader = if match inGhostHeader with None -> false | Some b -> b then parse_pure_decls else parse_decls_core and parse_decls_core = parser [< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/"); ds' = parse_decls_core >] -> ds @ ds' | [< _ = opt (parser [< '(_, Kwd "public") >] -> ()); abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false); final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] -> ExtensibleClass); ds = begin parser let rec parse_decls ?inGhostHeader = if match inGhostHeader with None -> false | Some b -> b then parse_pure_decls else parse_decls_core and parse_decls_core = parser [< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/"); ds' = parse_decls_core >] -> ds @ ds' | [< _ = opt (parser [< '(_, Kwd "public") >] -> ()); abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false); final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] -> ExtensibleClass); ds = begin parser let rec parse_decls ?inGhostHeader = if match inGhostHeader with None -> false | Some b -> b then parse_pure_decls else parse_decls_core and parse_decls_core = parser [< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/"); ds' = parse_decls_core >] -> ds @ ds' | [< _ = opt (parser [< '(_, Kwd "public") >] -> ()); abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false); final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] -> ExtensibleClass); ds = begin parser let rec parse_decls ?inGhostHeader = if match inGhostHeader with None -> false | Some b -> b then parse_pure_decls else parse_decls_core and parse_decls_core = parser [< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/"); ds' = parse_decls_core >] -> ds @ ds' | [< _ = opt (parser [< '(_, Kwd "public") >] -> ()); abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false); final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] -> ExtensibleClass); ds = begin parser let rec parse_decls ?inGhostHeader = if match inGhostHeader with None -> false | Some b -> b then parse_pure_decls else parse_decls_core and parse_decls_core = parser [< '((p1, _), Kwd "/*@"); ds = parse_pure_decls; '((_, p2), Kwd "@*/"); ds' = parse_decls_core >] -> ds @ ds' | [< _ = opt (parser [< '(_, Kwd "public") >] -> ()); abstract = (parser [< '(_, Kwd "abstract") >] -> true | [< >] -> false); final = (parser [< '(_, Kwd "final") >] -> FinalClass | [< >] -> ExtensibleClass); ds = begin parser
  • 7. Why modify VeriFast parser? #1Why modify VeriFast parser? #1Why modify VeriFast parser? #1Why modify VeriFast parser? #1Why modify VeriFast parser? #1
  • 8. Why modify VeriFast parser? #2Why modify VeriFast parser? #2Why modify VeriFast parser? #2Why modify VeriFast parser? #2Why modify VeriFast parser? #2 ☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.☆ Real usage needs two C language headers.☆ Real usage needs two C language headers. ☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.☆ Original C header is for compiling C code.☆ Original C header is for compiling C code. ☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code.☆ Pseud C header is for verifying C code. ☆ They may have some semantic gaps, which cause miss verification. ☆ They may have some semantic gaps, which cause miss verification. ☆ They may have some semantic gaps, which cause miss verification. ☆ They may have some semantic gaps, which cause miss verification. ☆ They may have some semantic gaps, which cause miss verification. ☆ Because VeriFast's parser is a subset of C99 parser. ☆ Because VeriFast's parser is a subset of C99 parser. ☆ Because VeriFast's parser is a subset of C99 parser. ☆ Because VeriFast's parser is a subset of C99 parser. ☆ Because VeriFast's parser is a subset of C99 parser.
  • 9. What is a near-term goal?What is a near-term goal?What is a near-term goal?What is a near-term goal?What is a near-term goal? ☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard.☆ Getting C99 compatible parser is hard. ☆ Let's verify "kern/subr_optstr.c" file in NetBSD kernel: ☆ Let's verify "kern/subr_optstr.c" file in NetBSD kernel: ☆ Let's verify "kern/subr_optstr.c" file in NetBSD kernel: ☆ Let's verify "kern/subr_optstr.c" file in NetBSD kernel: ☆ Let's verify "kern/subr_optstr.c" file in NetBSD kernel: $ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools $ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC $ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c $ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools $ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC $ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c $ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools $ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC $ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c $ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools $ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC $ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c $ sh build.sh -U -u -j 4 -T obj/tooldir -m amd64 tools $ sh build.sh -U -u -j 1 -T obj/tooldir -m amd64 kernel=GENERIC $ vfide -D __STDC__ -D __GNUC__ -D _KERNEL -D __ELF__ -D NO_KERNEL_RCSIDS -I sys -I sys/arch/amd64/compile/obj/GENERIC sys/kern/subr_optstr.c ☆ The kernel code is found at following:☆ The kernel code is found at following:☆ The kernel code is found at following:☆ The kernel code is found at following:☆ The kernel code is found at following: ☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src☆ https://github.com/IIJ-NetBSD/netbsd-src
  • 10. Original verifierOriginal verifierOriginal verifierOriginal verifierOriginal verifier
  • 11. Modified verifierModified verifierModified verifierModified verifierModified verifier
  • 12. My patches for VeriFast's parserMy patches for VeriFast's parserMy patches for VeriFast's parserMy patches for VeriFast's parserMy patches for VeriFast's parser * Parse semicolon without any declarations #121 https://github.com/verifast/verifast/pull/121 * Allow hardtab in string literals #120 https://github.com/verifast/verifast/pull/120 * Ignore inline keyword at static function declaration #119 https://github.com/verifast/verifast/pull/119 * Support operators in macros / Add -D option #116 https://github.com/verifast/verifast/pull/116 * Parse semicolon without any declarations #121 https://github.com/verifast/verifast/pull/121 * Allow hardtab in string literals #120 https://github.com/verifast/verifast/pull/120 * Ignore inline keyword at static function declaration #119 https://github.com/verifast/verifast/pull/119 * Support operators in macros / Add -D option #116 https://github.com/verifast/verifast/pull/116 * Parse semicolon without any declarations #121 https://github.com/verifast/verifast/pull/121 * Allow hardtab in string literals #120 https://github.com/verifast/verifast/pull/120 * Ignore inline keyword at static function declaration #119 https://github.com/verifast/verifast/pull/119 * Support operators in macros / Add -D option #116 https://github.com/verifast/verifast/pull/116 * Parse semicolon without any declarations #121 https://github.com/verifast/verifast/pull/121 * Allow hardtab in string literals #120 https://github.com/verifast/verifast/pull/120 * Ignore inline keyword at static function declaration #119 https://github.com/verifast/verifast/pull/119 * Support operators in macros / Add -D option #116 https://github.com/verifast/verifast/pull/116 * Parse semicolon without any declarations #121 https://github.com/verifast/verifast/pull/121 * Allow hardtab in string literals #120 https://github.com/verifast/verifast/pull/120 * Ignore inline keyword at static function declaration #119 https://github.com/verifast/verifast/pull/119 * Support operators in macros / Add -D option #116 https://github.com/verifast/verifast/pull/116
  • 13. Knowledge to debug parser #1-1Knowledge to debug parser #1-1Knowledge to debug parser #1-1Knowledge to debug parser #1-1Knowledge to debug parser #1-1 ☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace.☆ Don't catch exception to get stack trace. $ git diff diff --git a/src/vfconsole.ml b/src/vfconsole.ml index 8846dcb5..9204c2a4 100644 --- a/src/vfconsole.ml +++ b/src/vfconsole.ml @@ -23,7 +23,6 @@ let _ = Java_frontend_bridge.unload(); with PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1 - | ParseException (l, msg) -> print_msg l ("Parse error" ^ ... | CompilationError(msg) -> print_endline (msg); exit 1 | StaticError (l, msg, url) -> print_msg l msg; exit 1 | SymbolicExecutionError (ctxts, l, msg, url) -> $ git diff diff --git a/src/vfconsole.ml b/src/vfconsole.ml index 8846dcb5..9204c2a4 100644 --- a/src/vfconsole.ml +++ b/src/vfconsole.ml @@ -23,7 +23,6 @@ let _ = Java_frontend_bridge.unload(); with PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1 - | ParseException (l, msg) -> print_msg l ("Parse error" ^ ... | CompilationError(msg) -> print_endline (msg); exit 1 | StaticError (l, msg, url) -> print_msg l msg; exit 1 | SymbolicExecutionError (ctxts, l, msg, url) -> $ git diff diff --git a/src/vfconsole.ml b/src/vfconsole.ml index 8846dcb5..9204c2a4 100644 --- a/src/vfconsole.ml +++ b/src/vfconsole.ml @@ -23,7 +23,6 @@ let _ = Java_frontend_bridge.unload(); with PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1 - | ParseException (l, msg) -> print_msg l ("Parse error" ^ ... | CompilationError(msg) -> print_endline (msg); exit 1 | StaticError (l, msg, url) -> print_msg l msg; exit 1 | SymbolicExecutionError (ctxts, l, msg, url) -> $ git diff diff --git a/src/vfconsole.ml b/src/vfconsole.ml index 8846dcb5..9204c2a4 100644 --- a/src/vfconsole.ml +++ b/src/vfconsole.ml @@ -23,7 +23,6 @@ let _ = Java_frontend_bridge.unload(); with PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1 - | ParseException (l, msg) -> print_msg l ("Parse error" ^ ... | CompilationError(msg) -> print_endline (msg); exit 1 | StaticError (l, msg, url) -> print_msg l msg; exit 1 | SymbolicExecutionError (ctxts, l, msg, url) -> $ git diff diff --git a/src/vfconsole.ml b/src/vfconsole.ml index 8846dcb5..9204c2a4 100644 --- a/src/vfconsole.ml +++ b/src/vfconsole.ml @@ -23,7 +23,6 @@ let _ = Java_frontend_bridge.unload(); with PreprocessorDivergence (l, msg) -> print_msg l msg; exit 1 - | ParseException (l, msg) -> print_msg l ("Parse error" ^ ... | CompilationError(msg) -> print_endline (msg); exit 1 | StaticError (l, msg, url) -> print_msg l msg; exit 1 | SymbolicExecutionError (ctxts, l, msg, url) ->
  • 14. Knowledge to debug parser #1-2Knowledge to debug parser #1-2Knowledge to debug parser #1-2Knowledge to debug parser #1-2Knowledge to debug parser #1-2 $ cat tab_in_printf.c #include <stdio.h> int main() { printf("Use hard tabn"); return 0; } $ OCAMLRUNPARAM=b verifast -c tab_in_printf.c tab_in_printf.c Fatal error: exception Lexer.ParseException(_, "") Raised at file "parser.ml", line 1627, characters 26-61 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 Called from file "verifast.ml", line 2922, characters 17-1023 Called from file "verifast.ml", line 3130, characters 18-460 $ cat tab_in_printf.c #include <stdio.h> int main() { printf("Use hard tabn"); return 0; } $ OCAMLRUNPARAM=b verifast -c tab_in_printf.c tab_in_printf.c Fatal error: exception Lexer.ParseException(_, "") Raised at file "parser.ml", line 1627, characters 26-61 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 Called from file "verifast.ml", line 2922, characters 17-1023 Called from file "verifast.ml", line 3130, characters 18-460 $ cat tab_in_printf.c #include <stdio.h> int main() { printf("Use hard tabn"); return 0; } $ OCAMLRUNPARAM=b verifast -c tab_in_printf.c tab_in_printf.c Fatal error: exception Lexer.ParseException(_, "") Raised at file "parser.ml", line 1627, characters 26-61 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 Called from file "verifast.ml", line 2922, characters 17-1023 Called from file "verifast.ml", line 3130, characters 18-460 $ cat tab_in_printf.c #include <stdio.h> int main() { printf("Use hard tabn"); return 0; } $ OCAMLRUNPARAM=b verifast -c tab_in_printf.c tab_in_printf.c Fatal error: exception Lexer.ParseException(_, "") Raised at file "parser.ml", line 1627, characters 26-61 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 Called from file "verifast.ml", line 2922, characters 17-1023 Called from file "verifast.ml", line 3130, characters 18-460 $ cat tab_in_printf.c #include <stdio.h> int main() { printf("Use hard tabn"); return 0; } $ OCAMLRUNPARAM=b verifast -c tab_in_printf.c tab_in_printf.c Fatal error: exception Lexer.ParseException(_, "") Raised at file "parser.ml", line 1627, characters 26-61 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 Called from file "verifast.ml", line 2922, characters 17-1023 Called from file "verifast.ml", line 3130, characters 18-460
  • 15. Knowledge to debug parser #2-1Knowledge to debug parser #2-1Knowledge to debug parser #2-1Knowledge to debug parser #2-1Knowledge to debug parser #2-1 ☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.☆ Dump "token" using debug functions.☆ Dump "token" using debug functions. let rec print_tokens_list tokens = match tokens with [(_, tok)] -> Printf.printf "%sn" (string_of_token tok) | (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok); print_tokens_list xs | [] -> Printf.printf "n" let rec print_tokens_stream tokens = Printf.printf "[n"; Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok)) tokens; Printf.printf "]n" let rec print_tokens_list tokens = match tokens with [(_, tok)] -> Printf.printf "%sn" (string_of_token tok) | (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok); print_tokens_list xs | [] -> Printf.printf "n" let rec print_tokens_stream tokens = Printf.printf "[n"; Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok)) tokens; Printf.printf "]n" let rec print_tokens_list tokens = match tokens with [(_, tok)] -> Printf.printf "%sn" (string_of_token tok) | (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok); print_tokens_list xs | [] -> Printf.printf "n" let rec print_tokens_stream tokens = Printf.printf "[n"; Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok)) tokens; Printf.printf "]n" let rec print_tokens_list tokens = match tokens with [(_, tok)] -> Printf.printf "%sn" (string_of_token tok) | (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok); print_tokens_list xs | [] -> Printf.printf "n" let rec print_tokens_stream tokens = Printf.printf "[n"; Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok)) tokens; Printf.printf "]n" let rec print_tokens_list tokens = match tokens with [(_, tok)] -> Printf.printf "%sn" (string_of_token tok) | (_, tok) :: xs -> Printf.printf "%s, " (string_of_token tok); print_tokens_list xs | [] -> Printf.printf "n" let rec print_tokens_stream tokens = Printf.printf "[n"; Stream.iter (fun (_, tok) -> Printf.printf " %sn" (string_of_token tok)) tokens; Printf.printf "]n"
  • 16. Knowledge to debug parser #3-1Knowledge to debug parser #3-1Knowledge to debug parser #3-1Knowledge to debug parser #3-1Knowledge to debug parser #3-1 ☆ Exception "Stream.Error" has a string parameter specified by "??". ☆ Exception "Stream.Error" has a string parameter specified by "??". ☆ Exception "Stream.Error" has a string parameter specified by "??". ☆ Exception "Stream.Error" has a string parameter specified by "??". ☆ Exception "Stream.Error" has a string parameter specified by "??". $ wc -l src/parser.ml 1801 src/parser.ml $ vi src/parser.ml $ wc -l src/parser.ml 1801 src/parser.ml $ vi src/parser.ml $ wc -l src/parser.ml 1801 src/parser.ml $ vi src/parser.ml $ wc -l src/parser.ml 1801 src/parser.ml $ vi src/parser.ml $ wc -l src/parser.ml 1801 src/parser.ml $ vi src/parser.ml let parse_c_file = parser [< (headers, _) = parse_include_directives ignore_eol verbose enforceAnnotations dataModel; ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false; _ = Stream.empty ?? "Stream.empty expected" (* <= *) >] -> (headers, [PackageDecl(dummy_loc,"",[],ds)]) in parse_c_file token_stream let parse_c_file = parser [< (headers, _) = parse_include_directives ignore_eol verbose enforceAnnotations dataModel; ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false; _ = Stream.empty ?? "Stream.empty expected" (* <= *) >] -> (headers, [PackageDecl(dummy_loc,"",[],ds)]) in parse_c_file token_stream let parse_c_file = parser [< (headers, _) = parse_include_directives ignore_eol verbose enforceAnnotations dataModel; ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false; _ = Stream.empty ?? "Stream.empty expected" (* <= *) >] -> (headers, [PackageDecl(dummy_loc,"",[],ds)]) in parse_c_file token_stream let parse_c_file = parser [< (headers, _) = parse_include_directives ignore_eol verbose enforceAnnotations dataModel; ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false; _ = Stream.empty ?? "Stream.empty expected" (* <= *) >] -> (headers, [PackageDecl(dummy_loc,"",[],ds)]) in parse_c_file token_stream let parse_c_file = parser [< (headers, _) = parse_include_directives ignore_eol verbose enforceAnnotations dataModel; ds = parse_decls CLang dataModel enforceAnnotations ~inGhostHeader:false; _ = Stream.empty ?? "Stream.empty expected" (* <= *) >] -> (headers, [PackageDecl(dummy_loc,"",[],ds)]) in parse_c_file token_stream
  • 17. Knowledge to debug parser #3-2Knowledge to debug parser #3-2Knowledge to debug parser #3-2Knowledge to debug parser #3-2Knowledge to debug parser #3-2 $ cat main.c ; #include <stdio.h> $ OCAMLRUNPARAM=b verifast -c main.c main.c Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <= Raised at file "parser.ml", line 1629, characters 6-312 Called from file "parser.ml", line 1634, characters 6-31 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 $ cat main.c ; #include <stdio.h> $ OCAMLRUNPARAM=b verifast -c main.c main.c Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <= Raised at file "parser.ml", line 1629, characters 6-312 Called from file "parser.ml", line 1634, characters 6-31 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 $ cat main.c ; #include <stdio.h> $ OCAMLRUNPARAM=b verifast -c main.c main.c Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <= Raised at file "parser.ml", line 1629, characters 6-312 Called from file "parser.ml", line 1634, characters 6-31 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 $ cat main.c ; #include <stdio.h> $ OCAMLRUNPARAM=b verifast -c main.c main.c Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <= Raised at file "parser.ml", line 1629, characters 6-312 Called from file "parser.ml", line 1634, characters 6-31 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18 $ cat main.c ; #include <stdio.h> $ OCAMLRUNPARAM=b verifast -c main.c main.c Fatal error: exception Lexer.Stream.Error("Stream.empty expected") # <= Raised at file "parser.ml", line 1629, characters 6-312 Called from file "parser.ml", line 1634, characters 6-31 Called from file "verifast.ml", line 2966, characters 12-185 Called from file "verifast1.ml", line 470, characters 6-13 Called from file "util.ml" (inlined), line 109, characters 15-18
  • 18. Let's join the VeriFast project!Let's join the VeriFast project!Let's join the VeriFast project!Let's join the VeriFast project!Let's join the VeriFast project! ☆ To verify C language on real world.☆ To verify C language on real world.☆ To verify C language on real world.☆ To verify C language on real world.☆ To verify C language on real world. ☆ To get better parser.☆ To get better parser.☆ To get better parser.☆ To get better parser.☆ To get better parser.
  • 19. Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回Ads: 静的コード解析の会 第7回 ☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12.☆ The meeting will be held on 2018-05-12. ☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/☆ https://metasepi.connpass.com/event/77398/ ☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like:☆ Discussing about static code analysis such like: ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C, FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast, Why3, boogie, cogent, corral, seL4, vcc, etc. ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C, FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast, Why3, boogie, cogent, corral, seL4, vcc, etc. ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C, FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast, Why3, boogie, cogent, corral, seL4, vcc, etc. ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C, FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast, Why3, boogie, cogent, corral, seL4, vcc, etc. ATS, B-Method, CBMC, Coq, Coverity Scan, CSP, Dafny, F*, Frama-C, FreeSafeTy, Infer, Isabelle, SATABS, SPARK, Spin, Uppaal, VDM, VeriFast, Why3, boogie, cogent, corral, seL4, vcc, etc. ☆ We are calling for presentation.☆ We are calling for presentation.☆ We are calling for presentation.☆ We are calling for presentation.☆ We are calling for presentation.
  • 20. Ads: Functional Ikamusume bookAds: Functional Ikamusume bookAds: Functional Ikamusume bookAds: Functional Ikamusume bookAds: Functional Ikamusume book ☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana.☆ You can buy a latest issue from Toranoana. http://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.htmlhttp://www.toranoana.jp/mailorder/article/04/0030/58/73/040030587376.html ☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it!☆ Translated VeriFast tutorial appears in it! ☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94.☆ And we are calling for article on Comiket 94. ☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24.☆ The abstract deadline is 2018-06-24. ☆ Please read following about CFA:☆ Please read following about CFA:☆ Please read following about CFA:☆ Please read following about CFA:☆ Please read following about CFA: ☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke☆ https://wiki.haskell.org/Books#Joke
  • 21. License of photosLicense of photosLicense of photosLicense of photosLicense of photos * Creative Commons BBB | Flickr https://www.flickr.com/photos/steren/2732488224/ Copyright: Steren Giannini / License: CC BY 2.0 * Smiling Camel | John Campbell | Flickr https://www.flickr.com/photos/104346167@N06/16765659629/ Copyright: John Campbell / License: Public domain * ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille | Flickr https://www.flickr.com/photos/paille-fr/8070924277/ Copyright: Paille / License: CC BY-SA 2.0 * Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr https://www.flickr.com/photos/joeflintham/4196385813/ Copyright: Joe Flintham / License: CC BY-SA 2.0 * Creative Commons BBB | Flickr https://www.flickr.com/photos/steren/2732488224/ Copyright: Steren Giannini / License: CC BY 2.0 * Smiling Camel | John Campbell | Flickr https://www.flickr.com/photos/104346167@N06/16765659629/ Copyright: John Campbell / License: Public domain * ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille | Flickr https://www.flickr.com/photos/paille-fr/8070924277/ Copyright: Paille / License: CC BY-SA 2.0 * Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr https://www.flickr.com/photos/joeflintham/4196385813/ Copyright: Joe Flintham / License: CC BY-SA 2.0 * Creative Commons BBB | Flickr https://www.flickr.com/photos/steren/2732488224/ Copyright: Steren Giannini / License: CC BY 2.0 * Smiling Camel | John Campbell | Flickr https://www.flickr.com/photos/104346167@N06/16765659629/ Copyright: John Campbell / License: Public domain * ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille | Flickr https://www.flickr.com/photos/paille-fr/8070924277/ Copyright: Paille / License: CC BY-SA 2.0 * Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr https://www.flickr.com/photos/joeflintham/4196385813/ Copyright: Joe Flintham / License: CC BY-SA 2.0 * Creative Commons BBB | Flickr https://www.flickr.com/photos/steren/2732488224/ Copyright: Steren Giannini / License: CC BY 2.0 * Smiling Camel | John Campbell | Flickr https://www.flickr.com/photos/104346167@N06/16765659629/ Copyright: John Campbell / License: Public domain * ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille | Flickr https://www.flickr.com/photos/paille-fr/8070924277/ Copyright: Paille / License: CC BY-SA 2.0 * Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr https://www.flickr.com/photos/joeflintham/4196385813/ Copyright: Joe Flintham / License: CC BY-SA 2.0 * Creative Commons BBB | Flickr https://www.flickr.com/photos/steren/2732488224/ Copyright: Steren Giannini / License: CC BY 2.0 * Smiling Camel | John Campbell | Flickr https://www.flickr.com/photos/104346167@N06/16765659629/ Copyright: John Campbell / License: Public domain * ritchie-thompson | 12 octobre 2011 : Décès de Dennis Ritchie… | Paille | Flickr https://www.flickr.com/photos/paille-fr/8070924277/ Copyright: Paille / License: CC BY-SA 2.0 * Spiral - BlakeWalk | Staircase in the Monument BlakeWalk, 7 … | Flickr https://www.flickr.com/photos/joeflintham/4196385813/ Copyright: Joe Flintham / License: CC BY-SA 2.0