From 2684b34bcbf0ad277c547e95d69b2ff0180c118e Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 31 May 2018 14:49:22 -0700 Subject: [PATCH] allow method invocation to have empty argument lists --- example.java | 7 +------ src/Language/Java/Assignment.hs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/example.java b/example.java index 3be01cb2b..eb60a2a92 100644 --- a/example.java +++ b/example.java @@ -1,7 +1,2 @@ -if (t instanceof VirtualMachineError) { - throw (VirtualMachineError) t; -} else if (t instanceof ThreadDeath) { - throw (ThreadDeath) t; -} else if (t instanceof LinkageError) { - throw (LinkageError) t; +public abstract class ConnectableFlowable extends Flowable { } diff --git a/src/Language/Java/Assignment.hs b/src/Language/Java/Assignment.hs index 55335ec2c..1f2e7ba06 100644 --- a/src/Language/Java/Assignment.hs +++ b/src/Language/Java/Assignment.hs @@ -295,7 +295,7 @@ generic = makeTerm <$> symbol Grammar.GenericType <*> children(Java.Syntax.Gener -- Q to help decide: do we lose anything by omitting the term? methodInvocation :: Assignment -methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (Expression.Call [] <$> (callFunction <$> term expression <*> optional (token AnonDot *> term expression)) <*> argumentList <*> emptyTerm) +methodInvocation = makeTerm <$> symbol MethodInvocation <*> children (Expression.Call [] <$> (callFunction <$> expression <*> optional (token AnonDot *> expression)) <*> (argumentList <|> pure []) <*> emptyTerm) where callFunction a (Just b) = makeTerm1 (Expression.MemberAccess a b) callFunction a Nothing = a @@ -325,7 +325,15 @@ interface = makeTerm <$> symbol InterfaceDeclaration <*> children (normal <|> an -- we won't make a term because we have a choice of a bunch of things package :: Assignment -package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) +-- package = makeTerm <$> symbol PackageDeclaration <*> children (Java.Syntax.Package <$> someTerm expression) +package = do + loc <- symbol PackageDeclaration -- location which is calling the symbol API + c <- children $ do + expressions <- someTerm expression + pure (Java.Syntax.Package expressions) + pure (makeTerm loc c) -- pure is re-wrapping it back into the outer context, which in this case is Assignment (ie., the return type of the function) + + enum :: Assignment enum = makeTerm <$> symbol Grammar.EnumDeclaration <*> children (Java.Syntax.EnumDeclaration <$> term identifier <*> manyTerm enumConstant)