Main window for the LL(1) interactive tutoring mode in SyntaxTutor. More...
#include <lltutorwindow.h>
Classes | |
struct | TreeNode |
TreeNode structure used to build derivation trees. More... | |
Signals | |
void | sessionFinished (int cntRight, int cntWrong) |
Public Member Functions | |
LLTutorWindow (const Grammar &grammar, TutorialManager *tm=nullptr, QWidget *parent=nullptr) | |
Constructs the LL(1) tutor window with a given grammar. | |
~LLTutorWindow () | |
QString | generateQuestion () |
Generates a question for the current state of the tutor. | |
void | updateState (bool isCorrect) |
Updates the tutor state after verifying user response. | |
QString | FormatGrammar (const Grammar &grammar) |
Formats a grammar for display in the chat interface. | |
void | addMessage (const QString &text, bool isUser) |
void | addWidgetMessage (QWidget *widget) |
< Add text message to chat | |
void | exportConversationToPdf (const QString &filePath) |
< Add widget (e.g., table, tree) | |
void | showTable () |
< Export chat to PDF | |
void | showTableForCPrime () |
Display the full LL(1) table in C' ex. | |
void | updateProgressPanel () |
void | animateLabelPop (QLabel *label) |
void | animateLabelColor (QLabel *label, const QColor &flashColor) |
void | wrongAnimation () |
Visual shake/flash for incorrect answer. | |
void | wrongUserResponseAnimation () |
Animation specific to user chat input. | |
void | markLastUserIncorrect () |
Marks last message as incorrect. | |
void | TeachFirstTree (const std::vector< std::string > &symbols, std::unordered_set< std::string > &first_set, int depth, std::unordered_set< std::string > &processing, QTreeWidgetItem *parent) |
std::unique_ptr< TreeNode > | buildTreeNode (const std::vector< std::string > &symbols, std::unordered_set< std::string > &first_set, int depth, std::vector< std::pair< std::string, std::vector< std::string > > > &active_derivations) |
int | computeSubtreeWidth (const std::unique_ptr< TreeNode > &node, int hSpacing) |
void | drawTree (const std::unique_ptr< TreeNode > &root, QGraphicsScene *scene, QPointF pos, int hSpacing, int vSpacing) |
void | showTreeGraphics (std::unique_ptr< TreeNode > root) |
bool | verifyResponse (const QString &userResponse) |
bool | verifyResponseForA (const QString &userResponse) |
bool | verifyResponseForA1 (const QString &userResponse) |
bool | verifyResponseForA2 (const QString &userResponse) |
bool | verifyResponseForB (const QString &userResponse) |
bool | verifyResponseForB1 (const QString &userResponse) |
bool | verifyResponseForB2 (const QString &userResponse) |
bool | verifyResponseForC () |
QString | solution (const std::string &state) |
QStringList | solutionForA () |
QString | solutionForA1 () |
QString | solutionForA2 () |
QSet< QString > | solutionForB () |
QSet< QString > | solutionForB1 () |
QSet< QString > | solutionForB2 () |
QString | feedback () |
QString | feedbackForA () |
QString | feedbackForA1 () |
QString | feedbackForA2 () |
QString | feedbackForAPrime () |
QString | feedbackForB () |
QString | feedbackForB1 () |
QString | feedbackForB2 () |
QString | feedbackForBPrime () |
QString | feedbackForC () |
QString | feedbackForCPrime () |
void | feedbackForB1TreeWidget () |
void | feedbackForB1TreeGraphics () |
QString | TeachFollow (const QString &nt) |
QString | TeachPredictionSymbols (const QString &ant, const production &conseq) |
QString | TeachLL1Table () |
void | handleTableSubmission (const QVector< QVector< QString > > &raw, const QStringList &colHeaders) |
Protected Member Functions | |
void | closeEvent (QCloseEvent *event) override |
bool | eventFilter (QObject *obj, QEvent *event) override |
Main window for the LL(1) interactive tutoring mode in SyntaxTutor.
This class guides students through the construction and analysis of LL(1) parsing tables. It uses a finite-state sequence to present progressively more complex tasks, verifies user responses, provides corrective feedback, and supports visualizations like derivation trees.
The tutor is designed to teach the student how the LL(1) table is built, not just test it — including interactive tasks, animated feedback, and hints.
Key features include:
TeachFirst
).
|
explicit |
Constructs the LL(1) tutor window with a given grammar.
grammar | The grammar to use during the session. |
tm | Optional pointer to the tutorial manager (for help overlays). |
parent | Parent widget. |
LLTutorWindow::~LLTutorWindow | ( | ) |
void LLTutorWindow::addMessage | ( | const QString & | text, |
bool | isUser ) |
void LLTutorWindow::addWidgetMessage | ( | QWidget * | widget | ) |
< Add text message to chat
void LLTutorWindow::animateLabelColor | ( | QLabel * | label, |
const QColor & | flashColor ) |
void LLTutorWindow::animateLabelPop | ( | QLabel * | label | ) |
std::unique_ptr< LLTutorWindow::TreeNode > LLTutorWindow::buildTreeNode | ( | const std::vector< std::string > & | symbols, |
std::unordered_set< std::string > & | first_set, | ||
int | depth, | ||
std::vector< std::pair< std::string, std::vector< std::string > > > & | active_derivations ) |
|
inlineoverrideprotected |
int LLTutorWindow::computeSubtreeWidth | ( | const std::unique_ptr< TreeNode > & | node, |
int | hSpacing ) |
void LLTutorWindow::drawTree | ( | const std::unique_ptr< TreeNode > & | root, |
QGraphicsScene * | scene, | ||
QPointF | pos, | ||
int | hSpacing, | ||
int | vSpacing ) |
|
overrideprotected |
void LLTutorWindow::exportConversationToPdf | ( | const QString & | filePath | ) |
< Add widget (e.g., table, tree)
QString LLTutorWindow::feedback | ( | ) |
QString LLTutorWindow::feedbackForA | ( | ) |
QString LLTutorWindow::feedbackForA1 | ( | ) |
QString LLTutorWindow::feedbackForA2 | ( | ) |
QString LLTutorWindow::feedbackForAPrime | ( | ) |
QString LLTutorWindow::feedbackForB | ( | ) |
QString LLTutorWindow::feedbackForB1 | ( | ) |
void LLTutorWindow::feedbackForB1TreeGraphics | ( | ) |
void LLTutorWindow::feedbackForB1TreeWidget | ( | ) |
QString LLTutorWindow::feedbackForB2 | ( | ) |
QString LLTutorWindow::feedbackForBPrime | ( | ) |
QString LLTutorWindow::feedbackForC | ( | ) |
QString LLTutorWindow::feedbackForCPrime | ( | ) |
QString LLTutorWindow::FormatGrammar | ( | const Grammar & | grammar | ) |
Formats a grammar for display in the chat interface.
grammar | The grammar to format. |
QString LLTutorWindow::generateQuestion | ( | ) |
Generates a question for the current state of the tutor.
void LLTutorWindow::handleTableSubmission | ( | const QVector< QVector< QString > > & | raw, |
const QStringList & | colHeaders ) |
void LLTutorWindow::markLastUserIncorrect | ( | ) |
Marks last message as incorrect.
|
signal |
void LLTutorWindow::showTable | ( | ) |
< Export chat to PDF
Display the full LL(1) table in C ex.
void LLTutorWindow::showTableForCPrime | ( | ) |
Display the full LL(1) table in C' ex.
void LLTutorWindow::showTreeGraphics | ( | std::unique_ptr< TreeNode > | root | ) |
QString LLTutorWindow::solution | ( | const std::string & | state | ) |
QStringList LLTutorWindow::solutionForA | ( | ) |
QString LLTutorWindow::solutionForA1 | ( | ) |
QString LLTutorWindow::solutionForA2 | ( | ) |
QSet< QString > LLTutorWindow::solutionForB | ( | ) |
QSet< QString > LLTutorWindow::solutionForB1 | ( | ) |
QSet< QString > LLTutorWindow::solutionForB2 | ( | ) |
void LLTutorWindow::TeachFirstTree | ( | const std::vector< std::string > & | symbols, |
std::unordered_set< std::string > & | first_set, | ||
int | depth, | ||
std::unordered_set< std::string > & | processing, | ||
QTreeWidgetItem * | parent ) |
QString LLTutorWindow::TeachFollow | ( | const QString & | nt | ) |
QString LLTutorWindow::TeachLL1Table | ( | ) |
QString LLTutorWindow::TeachPredictionSymbols | ( | const QString & | ant, |
const production & | conseq ) |
void LLTutorWindow::updateProgressPanel | ( | ) |
void LLTutorWindow::updateState | ( | bool | isCorrect | ) |
Updates the tutor state after verifying user response.
isCorrect | Whether the user answered correctly. |
bool LLTutorWindow::verifyResponse | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForA | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForA1 | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForA2 | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForB | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForB1 | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForB2 | ( | const QString & | userResponse | ) |
bool LLTutorWindow::verifyResponseForC | ( | ) |
void LLTutorWindow::wrongAnimation | ( | ) |
Visual shake/flash for incorrect answer.
void LLTutorWindow::wrongUserResponseAnimation | ( | ) |
Animation specific to user chat input.