/** * Parses a string and extract VT100 control sequence information. * @param seq The string to parse. * @param values A pointer to an array that will hold the resultant values. The memory must already be allocated. * @param numValues A pointer to an integer that will hold the number of resultant values. * @param seqLength A pointer to an integer that will hold the length of the control sequence. * @return The token number that identifies the type of the control sequence. */ int ControlSeqParser::parse(const char *seq, int *values, int *numValues, int *seqLength) { int result = CS_UNKNOWN; if (seq != NULL) { m_seq = seq; result = parseSeq(); } if (seqLength != NULL) { *seqLength = 0; } if (result != CS_UNKNOWN) { if (seqLength != NULL) { *seqLength = m_currentPos; } if (numValues != NULL) { *numValues = m_numValues; } if (values != NULL) { for (int i=0; i < MAX_NUM_VALUES && i < m_numValues; i++) { values[i] = m_values[i]; } } } return result; }
static Node* parseUnion(const char*& nextChar,Uptr groupDepth) { Node* result = nullptr; while(true) { Node* newNode = parseSeq(nextChar,groupDepth); result = result ? new Alt(result,newNode) : newNode; switch(*nextChar) { case ')': if(groupDepth == 0) { Errors::fatalf("unexpected ')'"); } return result; case 0: if(groupDepth != 0) { Errors::fatalf("unexpected end of string"); } return result; case '|': ++nextChar; break; default: Errors::fatalf("unrecognized input"); }; }; }