" + identifier + "
", 0.0, identifier}; + + m_LastTokenPozition = m_Column; + + return token; +} + +inline Token Tokenizer::ProduceKeywordToken(TokenType type, const IPLString& keyword) { + auto token = Token { type, m_Line, m_LastTokenPozition, "" + keyword + "
", 0.0, keyword}; + + m_LastTokenPozition = m_Column; + + return token; +} + +inline Token Tokenizer::ProduceStringToken(TokenType type, const IPLString& str) { + auto token = Token { type, m_Line, m_LastTokenPozition, "" + str + "
", 0.0, str}; + + m_LastTokenPozition = m_Column; + + return token; +} + +inline Token Tokenizer::ProduceCommentToken(TokenType type, const IPLString& comment) { + auto token = Token { type, m_Line, m_LastTokenPozition, "" + comment + "
", 0.0, comment}; + + m_LastTokenPozition = m_Column; + + return token; +} + +inline Token Tokenizer::ProduceToken(TokenType type, const IPLString& lexeme, double number = 0.0) +{ + auto token = Token{ type, m_Line, m_LastTokenPozition, lexeme, number }; + m_LastTokenPozition = m_Column; + return token; +} + +inline Token Tokenizer::ProduceSkipToken() +{ + return ProduceToken(TokenType::Invalid, ""); +} + +inline Token Tokenizer::ProduceSingleCharacterToken(TokenType type, const IPLString& operatorLexeme) { + auto token = Token { type, m_Line, m_LastTokenPozition, "" + operatorLexeme + "
", 0.0, operatorLexeme}; + + m_LastTokenPozition = m_Column; + + return token; +} + +inline Token Tokenizer::ProduceErrorToken() +{ + return ProduceToken(TokenType::Invalid, ""); +} + +inline Token Tokenizer::ProduceInvalidToken() +{ + SetError("Invalid or unexpected token"); + RETURN_ERROR(ProduceToken(TokenType::Invalid, "")); +} + +IPLString Tokenizer::ParseComment() +{ + auto start = m_Current; + + if (!Match('/')) + { + RETURN_FAIL(IPLString()); + } + + if (Match('/')) + { + while (!IsEnd(m_Code[m_Current]) && !IsNewLine(m_Code[m_Current])) + { + NextSymbol(); + } + RETURN_SUCCESS(IPLString(m_Code + start, m_Code + m_Current)) + } + else if (!Match('*')) + { + PreviousSymbol(); + RETURN_FAIL(IPLString()); + } + + while (!IsEnd(m_Code[m_Current])) + { + if (Match('*') && Match('/')) + { + RETURN_SUCCESS(IPLString(m_Code + start, m_Code + m_Current)); + } + NextSymbol(); + } + + SetError("unterminated comment"); + RETURN_ERROR(IPLString()); +} + +double Tokenizer::ParseNumber() +{ + if (!IsDigit(m_Code[m_Current])) + { + RETURN_FAIL(0.0); + } + + size_t parsedBytes = 0; + double number = std::stod(m_Code + m_Current, &parsedBytes); + m_Current += static_cast";
+
+ int currentDepth = 0;
+ int lengthSinceLastNewLine = 0;
+ for (int i = 0; i < result.tokens.size(); i++) {
+ Token token = result.tokens[i];
+ IPLString nonModifiedLexeme = token.nonModifiedLexeme;
+
+ lengthSinceLastNewLine += nonModifiedLexeme.length();
+ if (lengthSinceLastNewLine > lineLengthLimit) {
+ output.append("\n");
+
+ lengthSinceLastNewLine = 0;
+ }
+
+ if (token.Type == TokenType::LeftBrace) {
+ currentDepth++;
+ } else if (token.Type == TokenType::RightBrace) {
+ currentDepth--;
+ }
+
+ if (token.Type == TokenType::Number) {
+ output.append(std::to_string(token.Number));
+
+ continue;
+ }
+
+ output.append(token.Lexeme);
+
+ if (token.Type == TokenType::Keyword && result.tokens[i + 1].Type != TokenType::LeftSquareBracket && result.tokens[i + 1].Type != TokenType::Semicolon) {
+ output.append(" ");
+
+ continue;
+ }
+
+ if (token.Type == TokenType::Equal ||
+ token.Type == TokenType::EqualEqual ||
+ token.Type == TokenType::MinusEqual ||
+ token.Type == TokenType::PlusEqual ||
+ token.Type == TokenType::StarEqual ||
+ token.Type == TokenType::DivideEqual ||
+ token.Type == TokenType::RightSquareBracket ||
+ token.Type == TokenType::Comma ||
+ token.Type == TokenType::Modulo ||
+ token.Type == TokenType::LogicalAnd ||
+ token.Type == TokenType::LogicalOr ||
+ token.Type == TokenType::Division ||
+ token.Type == TokenType::Plus ||
+ token.Type == TokenType::Minus ||
+ token.Type == TokenType::Star ||
+ token.Type == TokenType::Less ||
+ token.Type == TokenType::Greater ||
+ token.Type == TokenType::BangEqual) {
+ output.append(" ");
+ }
+
+ if (token.Type == TokenType::RightParen && result.tokens[i + 1].Type != TokenType::Semicolon) {
+ output.append(" ");
+ }
+
+ if (token.Type == TokenType::Identifier) {
+ if (result.tokens[i + 1].Type != TokenType::Dot && result.tokens[i + 1].Type != TokenType::RightParen && result.tokens[i + 1].Type != TokenType::LeftParen && result.tokens[i + 1].Type != TokenType::Semicolon) {
+ output.append(" ");
+ }
+ }
+
+ if (token.Type == TokenType::RightBrace) {
+ output.append("\n");
+ }
+
+ if (token.Type == TokenType::Semicolon || token.Type == TokenType::LeftBrace || token.Type == TokenType::RightBrace || token.Type == TokenType::Comment) {
+ if (token.Type == TokenType::Semicolon && (result.tokens[i + 1].Type == TokenType::Identifier || result.tokens[i + 1].Type == TokenType::PlusPlus || result.tokens[i + 1].Type == TokenType::MinusMinus)) {
+ output.append(" ");
+
+ continue;
+ }
+
+ output.append("\n");
+
+ lengthSinceLastNewLine = 0;
+
+ if (result.tokens[i + 1].Type == TokenType::RightBrace) {
+ for (int i = 0; i < currentDepth - 1; i++) {
+ output.append("\t");
+ }
+
+ continue;
+ }
+
+ for (int i = 0; i < currentDepth; i++) {
+ output.append("\t");
+ }
+ }
+ }
+
+ output += "";
+
+ std::ofstream MyFile("output.html");
+
+ MyFile << output;
+
+ MyFile.close();
+
+ return 0;
+}
\ No newline at end of file
diff --git a/homework/62374/java2html/output.html b/homework/62374/java2html/output.html
new file mode 100644
index 00000000..5cfe0c2c
--- /dev/null
+++ b/homework/62374/java2html/output.html
@@ -0,0 +1,28 @@
+\ No newline at end of filepublic
class
Prime
{
+public
static
void
main
(
String
[
]
+args
)
{
+int
low
=
20.000000,
high
=
50.000000;
+while
(
low
<
high
)
{
+boolean
flag
=
false
;
+for
(
int
i
=
2.000000;
i
<=
low
/
2.000000;
++
i
)
{
+ +// condition for nonprime number
+if
(
low
%
i
==
0.000000)
{
+flag
=
true
;
+break
;
+}
+ +}
+ +if
(
!
flag
&&
low
!=
0.000000&&
low
!=
1.000000)
{
+System
.
out
.
(
low
+
" "
)
;
+}
+ +++
low
;
+}
+ +}
+ +}
+ +