X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=grammer%2Futil.jj;h=5b5446bb9c102c3882efd813cab07652ea4687be;hb=31b08158b486a3132a8a7e571f24ce83d2cfd04f;hp=7e8b0c3dc788f2420527ceb4840fa121bc727e52;hpb=1c06bc88ba6f7c5882d726207fa6e05e734cb1bd;p=cdsspec-compiler.git diff --git a/grammer/util.jj b/grammer/util.jj index 7e8b0c3..5b5446b 100644 --- a/grammer/util.jj +++ b/grammer/util.jj @@ -49,6 +49,12 @@ public class UtilParser { return parser.FuncDecl(); } + public static VariableDeclaration parseDeclaration(String line) + throws ParseException { + InputStream input = new ByteArrayInputStream(line.getBytes()); + UtilParser parser = new UtilParser(input); + return parser.Declaration(); + } public static String stringArray2String(ArrayList content) { StringBuilder sb = new StringBuilder(); @@ -274,7 +280,10 @@ String Type() : ( { type = "const"; } )? - (((str = .image | str = .image | str = .image) { type = type + " " + str; })? + ( + ((str = .image | str = .image | str = .image) { + type = type.equals("") ? type + str : type + " " + str; + })? ( name = ParseQualifiedName() { if (!type.equals("")) @@ -426,6 +435,17 @@ ArrayList FormalParamList() : } } +VariableDeclaration Declaration() : +{ + String type, param; +} +{ + (type = Type()) (param = .image) + { + return new VariableDeclaration(type, param); + } +} + VariableDeclaration TypeParam() : { String type, param;