fn convert_token(token: &Token, next_is_then:&mut bool) -> String{
    match token {
        Token::And                  => "and".to_string(),
        Token::Break                => "break".to_string(),
        Token::Else                 => "else".to_string(),
        Token::End                  => "end".to_string(),
        Token::False                => "false".to_string(),
        Token::For                  => "for".to_string(),
        Token::Function             => "function".to_string(),
        Token::In                   => "in".to_string(),
        Token::Local                => "local".to_string(),
        Token::Not                  => "not".to_string(),
        Token::Or                   => "or".to_string(),
        Token::Repeat               => "repeat".to_string(),
        Token::Return               => "return".to_string(),
        Token::True                 => "true".to_string(),
        Token::Until                => "until".to_string(),
        Token::While                => "while".to_string(),
        Token::Nil                  => "nil".to_string(),
        Token::VarArgs              => "...".to_string(),
        Token::LeftParenthesis      => "(".to_string(),
        Token::RightParenthesis     => ")".to_string(),
        Token::LeftCurly            => "{".to_string(),
        Token::RightCurly           => "}".to_string(),
        Token::LeftBracket          => "[".to_string(),
        Token::RightBracket         => "]".to_string(),
        Token::Period               => ".".to_string(),
        Token::Comma                => ",".to_string(),
        Token::Colon                => ":".to_string(),
        Token::SemiColon            => ";".to_string(),
        Token::AssignmentOperator   => "=".to_string(),
        Token::Concat               => "..".to_string(),
        Token::LengthOperator       => "#".to_string(),
        Token::Equal                => "==".to_string(),
        Token::NotEqual             =>"~=".to_string(),
        Token::GreaterThan          => ">".to_string(),
        Token::LessThan             => "<".to_string(),
        Token::GreaterOrEqual       => ">=".to_string(),
        Token::LessOrEqual          => "<=".to_string(),
        Token::Multiply             => "*".to_string(),
        Token::Divide               => "/".to_string(),
        Token::Modulus              => "%".to_string(),
        Token::Add                  => "+".to_string(),
        Token::Subtract             => "-".to_string(),
        Token::Exponent             => "^".to_string(),
        Token::Str(value)           => value.clone(),
        Token::Ident(value)         => escape_keywords(&replace_swe_chars(&value)),
        Token::Number(value)        => value.clone(),
        
        Token::Elseif => {
            *next_is_then = true;
            "elseif".to_string()
        },

        Token::If => {
            *next_is_then = true;
            "if".to_string()
        },

        Token::Do => (
            if *next_is_then {
                "then"
            } else {
                "do"
            }
        ).to_string(),
        
        _ => String::from("")
    }
}
/// Convert Token to Lua code (stored in a String).
Convert Token to Lua code (stored in a String).
Convert Token to Lua code ( stored in a String ) .
fn convert_token(token: &Token, next_is_then:&mut bool) -> String{
    match token {
        Token::And                  => "and".to_string(),
        Token::Break                => "break".to_string(),
        Token::Else                 => "else".to_string(),
        Token::End                  => "end".to_string(),
        Token::False                => "false".to_string(),
        Token::For                  => "for".to_string(),
        Token::Function             => "function".to_string(),
        Token::In                   => "in".to_string(),
        Token::Local                => "local".to_string(),
        Token::Not                  => "not".to_string(),
        Token::Or                   => "or".to_string(),
        Token::Repeat               => "repeat".to_string(),
        Token::Return               => "return".to_string(),
        Token::True                 => "true".to_string(),
        Token::Until                => "until".to_string(),
        Token::While                => "while".to_string(),
        Token::Nil                  => "nil".to_string(),
        Token::VarArgs              => "...".to_string(),
        Token::LeftParenthesis      => "(".to_string(),
        Token::RightParenthesis     => ")".to_string(),
        Token::LeftCurly            => "{".to_string(),
        Token::RightCurly           => "}".to_string(),
        Token::LeftBracket          => "[".to_string(),
        Token::RightBracket         => "]".to_string(),
        Token::Period               => ".".to_string(),
        Token::Comma                => ",".to_string(),
        Token::Colon                => ":".to_string(),
        Token::SemiColon            => ";".to_string(),
        Token::AssignmentOperator   => "=".to_string(),
        Token::Concat               => "..".to_string(),
        Token::LengthOperator       => "#".to_string(),
        Token::Equal                => "==".to_string(),
        Token::NotEqual             =>"~=".to_string(),
        Token::GreaterThan          => ">".to_string(),
        Token::LessThan             => "<".to_string(),
        Token::GreaterOrEqual       => ">=".to_string(),
        Token::LessOrEqual          => "<=".to_string(),
        Token::Multiply             => "*".to_string(),
        Token::Divide               => "/".to_string(),
        Token::Modulus              => "%".to_string(),
        Token::Add                  => "+".to_string(),
        Token::Subtract             => "-".to_string(),
        Token::Exponent             => "^".to_string(),
        Token::Str(value)           => value.clone(),
        Token::Ident(value)         => escape_keywords(&replace_swe_chars(&value)),
        Token::Number(value)        => value.clone(),
        Token::Elseif => {
            *next_is_then = true;
            "elseif".to_string()
        },
        Token::If => {
            *next_is_then = true;
            "if".to_string()
        },
        Token::Do => (
            if *next_is_then {
                "then"
            } else {
                "do"
            }
        ).to_string(),
        _ => String::from("")
    }
}
fn convert_token ( token : & Token , next_is_then : & mut bool ) -> String { match token { Token :: And => " " . to_string ( ) , Token :: Break => " " . to_string ( ) , Token :: Else => " " . to_string ( ) , Token :: End => " " . to_string ( ) , Token :: False => " " . to_string ( ) , Token :: For => " " . to_string ( ) , Token :: Function => " " . to_string ( ) , Token :: In => " " . to_string ( ) , Token :: Local => " " . to_string ( ) , Token :: Not => " " . to_string ( ) , Token :: Or => " " . to_string ( ) , Token :: Repeat => " " . to_string ( ) , Token :: Return => " " . to_string ( ) , Token :: True => " " . to_string ( ) , Token :: Until => " " . to_string ( ) , Token :: While => " " . to_string ( ) , Token :: Nil => " " . to_string ( ) , Token :: VarArgs => " " . to_string ( ) , Token :: LeftParenthesis => " " . to_string ( ) , Token :: RightParenthesis => " " . to_string ( ) , Token :: LeftCurly => " " . to_string ( ) , Token :: RightCurly => " " . to_string ( ) , Token :: LeftBracket => " " . to_string ( ) , Token :: RightBracket => " " . to_string ( ) , Token :: Period => " " . to_string ( ) , Token :: Comma => " " . to_string ( ) , Token :: Colon => " " . to_string ( ) , Token :: SemiColon => " " . to_string ( ) , Token :: AssignmentOperator => " " . to_string ( ) , Token :: Concat => " " . to_string ( ) , Token :: LengthOperator => " " . to_string ( ) , Token :: Equal => " " . to_string ( ) , Token :: NotEqual => " " . to_string ( ) , Token :: GreaterThan => " " . to_string ( ) , Token :: LessThan => " " . to_string ( ) , Token :: GreaterOrEqual => " " . to_string ( ) , Token :: LessOrEqual => " " . to_string ( ) , Token :: Multiply => " " . to_string ( ) , Token :: Divide => " " . to_string ( ) , Token :: Modulus => " " . to_string ( ) , Token :: Add => " " . to_string ( ) , Token :: Subtract => " " . to_string ( ) , Token :: Exponent => " " . to_string ( ) , Token :: Str ( value ) => value . clone ( ) , Token :: Ident ( value ) => escape_keywords ( & replace_swe_chars ( & value ) ) , Token :: Number ( value ) => value . clone ( ) , Token :: Elseif => { * next_is_then = true ; " " . to_string ( ) } , Token :: If => { * next_is_then = true ; " " . to_string ( ) } , Token :: Do => ( if * next_is_then { " " } else { " " } ) . to_string ( ) , _ => String :: from ( " " ) } }
Convert Token to Lua code (stored in a String).
Convert Token to Lua code ( stored in a String ) .
token
&Token
next_is_then
&mut bool
token
&Token
next_is_then
&mut bool