-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: cf_solver
Are you sure you want to change the base?
Conversation
# 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
/** | ||
* Only linear input | ||
*/ | ||
fun constructIncremental(delta: RSMState, isRemoving: Boolean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему бы не выставить две функции в духе "добавить" и "удалить", а не флаг, который сложно трактовать, если не понимать, о чём речь?
There was a problem hiding this comment.
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!!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Больше восклицательных знаков!)
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему не записать как одно логическое выражение?
There was a problem hiding this comment.
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 ]] |
There was a problem hiding this comment.
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)*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
На первом работает, добавила тесты
Надоело строить RSM дельты руками, добавила класс который строит ее из регулярки и переданного нетерминала.
На второй входит в вечный цикл))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А как в такой язык что-то линейное добавить? Вход (c S d)*
с циклом.
Вот и циклится.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так. Тут же есть пустая цепочка из S. Так что должно терминироваться.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ща. Или вопрос в том, что в динамиве добавлять? Так что-нибуль типа S -> v
, чтобы v
в "скобочках" выводилось
453dd29
to
2b1e9ee
Compare
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)