Parser -> Function signature
This commit is contained in:
parent
f61994fab2
commit
4564f52c4c
1 changed files with 28 additions and 2 deletions
|
@ -48,6 +48,7 @@ public class JavaParser extends Parser<JavaFile> {
|
|||
//- Type
|
||||
//- Value
|
||||
//- Variable
|
||||
//- Function
|
||||
//- Class
|
||||
//- Import
|
||||
//- Package
|
||||
|
@ -148,9 +149,9 @@ public class JavaParser extends Parser<JavaFile> {
|
|||
|
||||
//VARIABLE
|
||||
StateTree<JavaFile> variable = new StateTree<>();
|
||||
StateTree<JavaFile> variable_mod = variable.then(new RedirectStateTree<>(modifier, (global, local) -> global.set("modifier", local)));
|
||||
StateTree<JavaFile> variable_type = variable.then(new RedirectStateTree<>(type, (global, local) -> global.set("type", local)));
|
||||
variable.then(new RedirectStateTree<>(modifier, (global, local) -> global.set("modifier", local)))
|
||||
.then(variable_type);
|
||||
variable_mod.then(variable_type);
|
||||
StateTree<JavaFile> variable_name = variable_type.then((validator) -> validator.validate(
|
||||
(token) -> token.getType().equals(TokenType.NAME),
|
||||
(bag, token) -> bag.set(token)));
|
||||
|
@ -164,8 +165,33 @@ public class JavaParser extends Parser<JavaFile> {
|
|||
variable_value.then((validator) -> validator.validate((token) -> token.getValue().equals(";")))
|
||||
.end((a,b) -> a);
|
||||
|
||||
//FUNCTION
|
||||
StateTree<JavaFile> function = new StateTree<>();
|
||||
StateTree<JavaFile> function_mod = function.then(new RedirectStateTree<>(modifier, (global, local) -> global.set("modifier", local)));
|
||||
StateTree<JavaFile> function_type = function.then(new RedirectStateTree<>(type, (global, local) -> global.set("type", local)));
|
||||
function_mod.then(function_type);
|
||||
function.then((validator) -> validator.validate((token) -> token.getValue().equals("static"))).end((a,b) -> a);
|
||||
StateTree<JavaFile> function_name = function_type.then((validator) -> validator.validate(
|
||||
(token) -> token.getType().equals(TokenType.NAME),
|
||||
(bag, token) -> bag.set(token)));
|
||||
StateTree<JavaFile> function_begin = function_name.then((validator) -> validator.validate((token) -> token.getValue().equals("(")));
|
||||
StateTree<JavaFile> function_end = function_begin.then((validator) -> validator.validate((token) -> token.getValue().equals(")")));
|
||||
function_end.end((a,b) -> a);
|
||||
|
||||
StateTree<JavaFile> function_throws = function_end.then((validator) -> validator.validate((token) -> token.getValue().equals("throws")))
|
||||
.then(new RedirectStateTree<>(type, (global, local) -> global.set(null)));
|
||||
function_throws.end((a,b) -> a);
|
||||
function_throws.then((validator) -> validator.validate((token) -> token.getValue().equals(","))).then(function_throws);
|
||||
|
||||
|
||||
StateTree<JavaFile> function_arg_type = function_begin.then(new RedirectStateTree<>(type, (global, local) -> global.set(null)));
|
||||
StateTree<JavaFile> function_arg_name = function_arg_type.then((validator) -> validator.validate((token) -> token.getType().equals(TokenType.NAME)));
|
||||
function_arg_name.then((validator) -> validator.validate((token) -> token.getValue().equals(","))).then(function_arg_type);
|
||||
function_arg_name.then(function_end);
|
||||
|
||||
StateTree<JavaFile> clazz_container = new StateTree<>();
|
||||
clazz_container.then(variable);
|
||||
clazz_container.then(function);
|
||||
|
||||
//CLASS
|
||||
StateTree<JavaFile> clazz_ = new StateTree<>();
|
||||
|
|
Loading…
Add table
Reference in a new issue