License | GNU LGPLv3 |
---|---|
Maintainer | paul.bittner@uni-ulm.de |
Safe Haskell | Safe |
Synopsis
- data SimpleJavaGrammar
- type SJavaAST a = AST SimpleJavaGrammar a
- type SSJavaAST = SJavaAST String
- type SJavaState = Tree (State UUID (Node SimpleJavaGrammar String))
- sjava_methoddef :: String -> String -> [(String, String)] -> [SJavaState] -> SJavaState
- sjava_parametersdef :: [(String, String)] -> SJavaState
- sjava_args :: [SJavaState] -> SJavaState
- sjava_statements :: [SJavaState] -> SJavaState
- sjava_exprstatement :: SJavaState -> SJavaState
- sjava_assignment :: SJavaState -> String -> SJavaState -> SJavaState
- sjava_return :: SJavaState -> SJavaState
- sjava_condition :: SJavaState -> [SJavaState] -> SJavaState
- sjava_funccall :: String -> [SJavaState] -> SJavaState
- sjava_expr :: SJavaState -> SJavaState
- sjava_unaryop :: String -> SJavaState -> SJavaState
- sjava_binaryop :: SJavaState -> String -> SJavaState -> SJavaState
- sjava_vardecl :: String -> String -> SJavaState
- sjava_varref :: String -> SJavaState
- sjava_literal :: String -> SJavaState
- sjava_type :: String -> SJavaState
- sjava_file :: String -> [SJavaState] -> SJavaState
Documentation
data SimpleJavaGrammar Source #
Simplified subset of the Java grammar.
SJava_MethodDef | Rule for method definitions. |
SJava_ParametersDef | Rule for a parameters list (e.g., in a method declaration). |
SJava_Args | Rule for arguments passed to a method call (e.g., |
SJava_Statements | Rule for a sequential list of statements (e.g., inside a method). |
SJava_ExprStatement | Rule for a statement that is a single expression (e.g., |
SJava_Assignment | Rule for assignments of variables (e.g., |
SJava_Return | Rule for |
SJava_Condition | Rule for conditions ( |
SJava_FuncCall | Rule for function calls. |
SJava_Expression | Rule for expressions (e.g., |
SJava_UnaryOp | Rule for unary operations (e.g., |
SJava_BinaryOp | Rule for binary operations (e.g., |
SJava_VarDecl | Rule for variable declarations (e.g., |
SJava_VarRef | Rule for variable references. |
SJava_Literal | Rule for literals. |
SJava_Type | Rule for types (e.g., |
SJava_File | Rule that represents an entire file. Usually the root of the AST. |
Instances
Eq SimpleJavaGrammar Source # | |
Defined in SimpleJava (==) :: SimpleJavaGrammar -> SimpleJavaGrammar -> Bool (/=) :: SimpleJavaGrammar -> SimpleJavaGrammar -> Bool | |
Show SimpleJavaGrammar Source # | |
Defined in SimpleJava showsPrec :: Int -> SimpleJavaGrammar -> ShowS show :: SimpleJavaGrammar -> String showList :: [SimpleJavaGrammar] -> ShowS | |
Grammar SimpleJavaGrammar Source # | Define optionality for all node types in our Java grammar |
Defined in SimpleJava | |
ASTPrettyPrinter SimpleJavaGrammar Source # | |
Defined in SimpleJava prettyPrint :: Monoid b => b -> (Node SimpleJavaGrammar a -> Int -> b) -> (Node SimpleJavaGrammar a -> String -> b) -> (Node SimpleJavaGrammar a -> b) -> AST SimpleJavaGrammar a -> b Source # |
type SSJavaAST = SJavaAST String Source #
An AST
build from the SimpleJavaGrammar containing Strings as values.
type SJavaState = Tree (State UUID (Node SimpleJavaGrammar String)) Source #
sjava_methoddef :: String -> String -> [(String, String)] -> [SJavaState] -> SJavaState Source #
Construct a method definition with given (1) return type, (2) name, (3) parameters (pairs of type and name), and (4) the given content (list of statements).
sjava_parametersdef :: [(String, String)] -> SJavaState Source #
Construct a definition of parameters subtree from the given pairs of type and name.
sjava_args :: [SJavaState] -> SJavaState Source #
Construct an arguments subtree from the given list of subtrees (e.g., (1 + 2, "arg2", null)
).
sjava_statements :: [SJavaState] -> SJavaState Source #
Construct a statements block from a list of statements.
sjava_exprstatement :: SJavaState -> SJavaState Source #
Wrap the given subtree in an expression statement. The given tree should be an expression.
Pseudocode example: sjava_exprstatement 'x = 3 == 'x + 3;'
.
sjava_assignment :: SJavaState -> String -> SJavaState -> SJavaState Source #
Constructs an assignment where parameter
- represents the left side of the assignment (e.g., a variable that should be assigned a value),
- is the operator's name to use (e.g.,
"="
), and - is the expression to assign (e.g. "1 + 2").
sjava_return :: SJavaState -> SJavaState Source #
Constructs a return statement that returns the given expression.
sjava_condition :: SJavaState -> [SJavaState] -> SJavaState Source #
Constructs an if-block (without else case) with the given condition (first argument) and sequence of statements to run when the condition is met.
sjava_funccall :: String -> [SJavaState] -> SJavaState Source #
Constructs a call to a function the given name and a list of arguments to pass.
sjava_expr :: SJavaState -> SJavaState Source #
Wraps an tree in an expression. For example, a literal is an expression. Thus a literal can be used anywhere an expression required but should be wrapped into an expression first.
sjava_unaryop :: String -> SJavaState -> SJavaState Source #
Constructs a unary operation (e.g. -3
) from a given name (-
) that is applied to the given expression (3
).
sjava_binaryop :: SJavaState -> String -> SJavaState -> SJavaState Source #
Constructs a binary operator from a given name and two expressions.
sjava_vardecl :: String -> String -> SJavaState Source #
Constructs a variable declaration (e.g., int x;
) from a type (e.g., int
) and a name (e.g., x
).
sjava_varref :: String -> SJavaState Source #
Constructs a reference to a variable with the given name. The returned tree is a leaf.
sjava_literal :: String -> SJavaState Source #
Constructs a literal with the given name. The returned tree is a leaf.
sjava_type :: String -> SJavaState Source #
Constructs a type with the given name. The returned tree is a leaf.
sjava_file :: String -> [SJavaState] -> SJavaState Source #
Constructs a file with the given name and content.