开发者

Simple parser for JML

I am looking for a parser written in Java capable of reading JML.

Basically I would like the parser to be able to read a JML block and know to which method it be开发者_Python百科longs to.

I've been looking at the OpenJML project, but just the project setup is too much.


I doubt that you will find a tool that does exactly what you want, or even close to what you want.

You could write a "partial" Java grammar that scans an input file for //@ ... and /*@ ... @*/ directly followed by a method declaration. By "partial" I mean that you're not semantically parsing the input source, but perform this only on a lexical level (so tokens only). Make sure that you account for string literals: you wouldn't want the literal String s = "/*@"; to be the start of a JML spec.

Two well known parser generators for Java are:

  1. ANTLR
  2. JavaCC

Getting to grips with either one will take a bit of time, especially if you're new to parser generators, but once you get the hang of it, it really is not much work to create a small grammar that could do this reliably.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜