SyntaxTutor
Educational app designed to help compiler students understand LL(1) and SLR(1) parsing algorithms.
 
Loading...
Searching...
No Matches
LLTutorWindow Class Reference

Main window for the LL(1) interactive tutoring mode in SyntaxTutor. More...

#include <lltutorwindow.h>

Inheritance diagram for LLTutorWindow:
Collaboration diagram for LLTutorWindow:

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< TreeNodebuildTreeNode (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
 

Detailed Description

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:

  • Interactive question flow based on grammar analysis.
  • Derivation tree generation (TeachFirst).
  • Step-by-step verification of FIRST, FOLLOW, prediction symbols, and table entries.
  • Exportable conversation log for grading or review.

Constructor & Destructor Documentation

◆ LLTutorWindow()

LLTutorWindow::LLTutorWindow ( const Grammar & grammar,
TutorialManager * tm = nullptr,
QWidget * parent = nullptr )
explicit

Constructs the LL(1) tutor window with a given grammar.

Parameters
grammarThe grammar to use during the session.
tmOptional pointer to the tutorial manager (for help overlays).
parentParent widget.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~LLTutorWindow()

LLTutorWindow::~LLTutorWindow ( )

Member Function Documentation

◆ addMessage()

void LLTutorWindow::addMessage ( const QString & text,
bool isUser )
Here is the caller graph for this function:

◆ addWidgetMessage()

void LLTutorWindow::addWidgetMessage ( QWidget * widget)

< Add text message to chat

Here is the caller graph for this function:

◆ animateLabelColor()

void LLTutorWindow::animateLabelColor ( QLabel * label,
const QColor & flashColor )

◆ animateLabelPop()

void LLTutorWindow::animateLabelPop ( QLabel * label)

◆ buildTreeNode()

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 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeEvent()

void LLTutorWindow::closeEvent ( QCloseEvent * event)
inlineoverrideprotected
Here is the call graph for this function:

◆ computeSubtreeWidth()

int LLTutorWindow::computeSubtreeWidth ( const std::unique_ptr< TreeNode > & node,
int hSpacing )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawTree()

void LLTutorWindow::drawTree ( const std::unique_ptr< TreeNode > & root,
QGraphicsScene * scene,
QPointF pos,
int hSpacing,
int vSpacing )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

bool LLTutorWindow::eventFilter ( QObject * obj,
QEvent * event )
overrideprotected

◆ exportConversationToPdf()

void LLTutorWindow::exportConversationToPdf ( const QString & filePath)

< Add widget (e.g., table, tree)

◆ feedback()

QString LLTutorWindow::feedback ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForA()

QString LLTutorWindow::feedbackForA ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForA1()

QString LLTutorWindow::feedbackForA1 ( )
Here is the caller graph for this function:

◆ feedbackForA2()

QString LLTutorWindow::feedbackForA2 ( )
Here is the caller graph for this function:

◆ feedbackForAPrime()

QString LLTutorWindow::feedbackForAPrime ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForB()

QString LLTutorWindow::feedbackForB ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForB1()

QString LLTutorWindow::feedbackForB1 ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForB1TreeGraphics()

void LLTutorWindow::feedbackForB1TreeGraphics ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForB1TreeWidget()

void LLTutorWindow::feedbackForB1TreeWidget ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForB2()

QString LLTutorWindow::feedbackForB2 ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForBPrime()

QString LLTutorWindow::feedbackForBPrime ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feedbackForC()

QString LLTutorWindow::feedbackForC ( )
Here is the caller graph for this function:

◆ feedbackForCPrime()

QString LLTutorWindow::feedbackForCPrime ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatGrammar()

QString LLTutorWindow::FormatGrammar ( const Grammar & grammar)

Formats a grammar for display in the chat interface.

Parameters
grammarThe grammar to format.
Returns
A QString representation.
Here is the caller graph for this function:

◆ generateQuestion()

QString LLTutorWindow::generateQuestion ( )

Generates a question for the current state of the tutor.

Returns
A formatted question string.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleTableSubmission()

void LLTutorWindow::handleTableSubmission ( const QVector< QVector< QString > > & raw,
const QStringList & colHeaders )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ markLastUserIncorrect()

void LLTutorWindow::markLastUserIncorrect ( )

Marks last message as incorrect.

◆ sessionFinished

void LLTutorWindow::sessionFinished ( int cntRight,
int cntWrong )
signal
Here is the caller graph for this function:

◆ showTable()

void LLTutorWindow::showTable ( )

< Export chat to PDF

Display the full LL(1) table in C ex.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showTableForCPrime()

void LLTutorWindow::showTableForCPrime ( )

Display the full LL(1) table in C' ex.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showTreeGraphics()

void LLTutorWindow::showTreeGraphics ( std::unique_ptr< TreeNode > root)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solution()

QString LLTutorWindow::solution ( const std::string & state)
Here is the caller graph for this function:

◆ solutionForA()

QStringList LLTutorWindow::solutionForA ( )
Here is the caller graph for this function:

◆ solutionForA1()

QString LLTutorWindow::solutionForA1 ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solutionForA2()

QString LLTutorWindow::solutionForA2 ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solutionForB()

QSet< QString > LLTutorWindow::solutionForB ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solutionForB1()

QSet< QString > LLTutorWindow::solutionForB1 ( )
Here is the caller graph for this function:

◆ solutionForB2()

QSet< QString > LLTutorWindow::solutionForB2 ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TeachFirstTree()

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 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TeachFollow()

QString LLTutorWindow::TeachFollow ( const QString & nt)
Here is the caller graph for this function:

◆ TeachLL1Table()

QString LLTutorWindow::TeachLL1Table ( )
Here is the caller graph for this function:

◆ TeachPredictionSymbols()

QString LLTutorWindow::TeachPredictionSymbols ( const QString & ant,
const production & conseq )
Here is the caller graph for this function:

◆ updateProgressPanel()

void LLTutorWindow::updateProgressPanel ( )
Here is the caller graph for this function:

◆ updateState()

void LLTutorWindow::updateState ( bool isCorrect)

Updates the tutor state after verifying user response.

Parameters
isCorrectWhether the user answered correctly.
Here is the call graph for this function:

◆ verifyResponse()

bool LLTutorWindow::verifyResponse ( const QString & userResponse)
Here is the call graph for this function:

◆ verifyResponseForA()

bool LLTutorWindow::verifyResponseForA ( const QString & userResponse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyResponseForA1()

bool LLTutorWindow::verifyResponseForA1 ( const QString & userResponse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyResponseForA2()

bool LLTutorWindow::verifyResponseForA2 ( const QString & userResponse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyResponseForB()

bool LLTutorWindow::verifyResponseForB ( const QString & userResponse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyResponseForB1()

bool LLTutorWindow::verifyResponseForB1 ( const QString & userResponse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyResponseForB2()

bool LLTutorWindow::verifyResponseForB2 ( const QString & userResponse)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyResponseForC()

bool LLTutorWindow::verifyResponseForC ( )
Here is the caller graph for this function:

◆ wrongAnimation()

void LLTutorWindow::wrongAnimation ( )

Visual shake/flash for incorrect answer.

◆ wrongUserResponseAnimation()

void LLTutorWindow::wrongUserResponseAnimation ( )

Animation specific to user chat input.


The documentation for this class was generated from the following files: