Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic RSM update #9

Open
wants to merge 16 commits into
base: cf_solver
Choose a base branch
from
Open

Dynamic RSM update #9

wants to merge 16 commits into from

Conversation

bachish
Copy link
Collaborator

@bachish bachish commented Dec 14, 2023

  • Implement Incremental algorithm for dynamically editing RSM: enable to add and remove linear input from RSM.

Algorithm

Tests

Incremental Construction and Maintenance of Minimal Finite-State Automata (Carrasco & Forcada, CL 2002)

# Conflicts:
#	src/main/kotlin/org/srcgll/grammar/combinator/Grammar.kt
#	src/main/kotlin/org/srcgll/rsm/RSMState.kt
#	src/main/kotlin/org/srcgll/rsm/symbol/Nonterminal.kt
#	src/main/kotlin/org/srcgll/rsm/symbol/Terminal.kt
#	src/test/kotlin/TestRSMStringInputWIthSPPFRecovery.kt
#	src/test/kotlin/TestRSMStringInputWithSPPFFail.kt
#	src/test/kotlin/TestRSMStringInputWithSPPFSuccess.kt
#	src/test/kotlin/rsm/api/TerminalsEqualsTest.kt
#	src/test/kotlin/rsm/builder/AStarTest.kt
@bachish bachish linked an issue Dec 14, 2023 that may be closed by this pull request
/**
* Only linear input
*/
fun constructIncremental(delta: RSMState, isRemoving: Boolean) {
Copy link
Member

Choose a reason for hiding this comment

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

А почему бы не выставить две функции в духе "добавить" и "удалить", а не флаг, который сложно трактовать, если не понимать, о чём речь?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

У RSMState есть методы "добавить" и "удалить".
Обертка над этим методом с нужными флагами. Перенесла их в файл RSMState.

}
}
if (updatedStart == null) {
throw Exception("Start state should be updated!!")
Copy link
Member

Choose a reason for hiding this comment

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

Больше восклицательных знаков!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

!!!!

}

fun isFinal(): Boolean {
if (isRemoving && delta.isFinal) {
Copy link
Member

Choose a reason for hiding this comment

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

Почему не записать как одно логическое выражение?

Copy link
Collaborator Author

@bachish bachish Dec 21, 2023

Choose a reason for hiding this comment

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

тогда будет
!(isRemoving && delta.isFinal) && (origin.isFinal || delta.isFinal)
что мне кажется гораздо менее читабельно
придется каждый раз разбираться в этом условии

}

/**
* Grammar for language S = ( S ) | [[ S ]]
Copy link
Member

Choose a reason for hiding this comment

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

А можете ещё для полноценного Дика, который

S -> \eps | a S b S | c S d S

Или даже

S -> (a S b)* 

Copy link
Collaborator Author

@bachish bachish Dec 21, 2023

Choose a reason for hiding this comment

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

На первом работает, добавила тесты
Надоело строить RSM дельты руками, добавила класс который строит ее из регулярки и переданного нетерминала.

На второй входит в вечный цикл))

Copy link
Collaborator Author

@bachish bachish Dec 21, 2023

Choose a reason for hiding this comment

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

А как в такой язык что-то линейное добавить? Вход (c S d)* с циклом.
Вот и циклится.

Copy link
Member

Choose a reason for hiding this comment

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

Так. Тут же есть пустая цепочка из S. Так что должно терминироваться.

Copy link
Member

Choose a reason for hiding this comment

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

Ща. Или вопрос в том, что в динамиве добавлять? Так что-нибуль типа S -> v, чтобы v в "скобочках" выводилось

@bachish bachish force-pushed the cf_solver branch 2 times, most recently from 453dd29 to 2b1e9ee Compare December 25, 2023 16:08
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.

RSM modification
2 participants