Skip to content

LexerOfNumbers - #25

Open
Palezehvat wants to merge 2 commits into
mainfrom
lexerOfRealNumbers
Open

Palezehvat wants to merge 2 commits into
mainfrom
lexerOfRealNumbers

Conversation

@Palezehvat

Copy link
Copy Markdown
Owner

No description provided.

for (size_t i = 0; i < sizeString; ++i) {
switch (state)
{
case(0):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case(0):
case 0:


bool isTheSequenceANumber(const char* string) {
size_t sizeString = strlen(string);
int state = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хочется, чтобы state был enum-ом, с разумными названиями элементов

}
return false;
case(2):
if (string[i] == 'E' && string[i-1] != '.') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (string[i] == 'E' && string[i-1] != '.') {
if (string[i] == 'E' && string[i - 1] != '.') {

Но вообще нет, автомат так не умеет. string[i - 1], как и другие факты из прошлого, кодируются состояниями. Иначе таблица переходов была бы трёхмерной.

}

}
return string != NULL && string[sizeString - 1] != '+' && string[sizeString - 1] != '-' && string[sizeString - 1] != 'E';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так автоматы тоже не умеют. Надо либо явно return false при неверном переходе, либо return true из допускающего состояния

#pragma once
#include <stdbool.h>

bool isTheSequenceANumber(const char* string); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо комментарий

printf("ERROR...\n");
return -1;
}
printf("Input string no more than 100symbols\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf("Input string no more than 100symbols\n");
printf("Input string no more than 100 symbols\n");

#include <stdio.h>

int main() {
if (test()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отступы надо пробелами

#pragma once
#include <stdbool.h>

bool test(); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И даже тут надо комментарии

Comment on lines +1 to +2
#pragma once
#include <stdbool.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#pragma once
#include <stdbool.h>
#pragma once
#include <stdbool.h>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants