Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Statements */
- public static boolean statements(){
- if( statement() && statements() )
- {
- return true;
- }
- if( statements())
- return true;
- return false;
- }
- public static boolean statement(){
- if( simpleStmt() )
- {
- if(tokens.get(index).equals("$SEMICOLON"))
- {
- index++;
- stack.add(level + " ;");
- return true;
- }
- }
- if( statement_return() ) {
- if (tokens.get(index).equals("$SEMICOLON")) {
- index++;
- stack.add(level + " ;");
- return true;
- }
- }
- if( functionCall() )
- {
- if(tokens.get(index).equals("$SEMICOLON"))
- {
- index++;
- stack.add(level + " ;");
- return true;
- }
- }
- if( controlStmt())
- return true;
- return false;
- }
- public static boolean statement_return() {
- if(tokens.get(index).equals("$RETURN"))
- {
- index++;
- stack.add(level + " ;");
- if( expression() ) {
- return true;
- }
- // Reikia su return 0 kažką bbž padaryt
- }
- return false;
- }
- public static boolean functionCall() {
- if( functionName() ) {
- if(tokens.get(index).equals("$LBRACKET1")) {
- index++;
- stack.add(level + " '('");
- if (tokens.get(index).equals("$RBRACKET1")) {
- index++;
- stack.add(level + " ')'");
- return true;
- } else if (callParameters()) {
- if (tokens.get(index).equals("$RBRACKET1")) {
- index++;
- stack.add(level + " ')'");
- return true;
- }
- }
- }
- }
- return false;
- }
- public static boolean callParameters(){
- if( expression() ){
- if(tokens.get(index).equals("$COMMA") ){
- index++;
- stack.add(level + " ','");
- if( callParameters())
- return true;
- }
- else
- return true;
- }
- return false;
- }
- public static boolean simpleStmt()
- {
- if( statement_varDeclaration() )
- return true;
- if( statement_assignment( ))
- return true;
- if( io() )
- return true;
- return false;
- }
- public static boolean statement_varDeclaration()
- {
- if( type() )
- {
- if( variable() )
- {
- if(tokens.get(index).equals("$SEMICOLON"))
- {
- index++;
- stack.add(level + " ;");
- return true;
- }
- else if(tokens.get(index).equals("$ASSIGNMENT"))
- {
- index++;
- stack.add(level + " '='");
- if( expression())
- {
- if(tokens.get(index).equals("$SEMICOLON"))
- {
- index++;
- stack.add(level + " ;");
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- public static boolean statement_assignment()
- {
- if(variable())
- {
- if( assigment())
- {
- if( expression())
- return true;
- }
- }
- return false;
- }
- public static boolean io()
- {
- if( input( ))
- {
- return true;
- }
- if( output( ))
- {
- return true;
- }
- return false;
- }
- public static boolean input(){
- if(tokens.get(index).equals("$IN"))
- {
- index++;
- stack.add(level + " 'input'");
- if( variable() )
- return true;
- }
- return false;
- }
- public static boolean output(){
- if(tokens.get(index).equals("$OUT"))
- {
- index++;
- stack.add(level + " 'echo'");
- if( expression( ))
- return true;
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement