<commit_before>/**
 * @file    ANSIModephrase.hh
 * @author  <NAME> <<EMAIL>>
 * @license MIT
 * @created Tue Nov  8 14:19:15 UTC 2011
 */

#include "StateMachine.hh"
#include "ANSIModephrase.hh"
#include "Exception.hh"
#include "InvalidState.hh"
#include "CSIValue.hh"

/* A bit of Wikipedia background:
 * Escape sequences start with the character ESC (ASCII decimal 27/hex
 * 0x1B/octal 033). For two character sequences the second character is in
 * the range ASCII 64 to 95 (@ to _). Most of the sequences are however more
 * than two characters, and start with the characters ESC and [ (left bracket).
 * This sequence is called CSI for Control Sequence Introducer (or Control
 * Sequence Initiator). The final character of these sequences is in the range
 * ASCII 64 to 126 (@ to ~).
 */

void ANSIModephrase::feed( char c ) {
	/* OK. We're escaped. Let's find out if we could have
	   a CSI entry, or a private-mode ANSI escape sequence */
	if ( c == '[' ) {
		/* OK. We've hit a CSI escape sequence. */
		ansi_next_state = &ansi_state_CSIValue;
	} else if ( c >= '@' && c <= '_' ) {
		/* We've hit a private-mode escape sequence */
	} else {
		/* We've hit garbage. */
		ansi_next_state = &ansi_state_InvalidState;
		throw new InvalidSequence();
	}
}

void ANSIModephrase::enter() {}
void ANSIModephrase::exit()  {}

ANSIModephrase ansi_state_ANSIModephrase;<commit_msg>Private mode parsing is totally unimplemented<commit_after>/**
 * @file    ANSIModephrase.hh
 * @author  <NAME> <<EMAIL>>
 * @license MIT
 * @created Tue Nov  8 14:19:15 UTC 2011
 */

#include "StateMachine.hh"
#include "ANSIModephrase.hh"
#include "Exception.hh"
#include "InvalidState.hh"
#include "CSIValue.hh"

/* A bit of Wikipedia background:
 * Escape sequences start with the character ESC (ASCII decimal 27/hex
 * 0x1B/octal 033). For two character sequences the second character is in
 * the range ASCII 64 to 95 (@ to _). Most of the sequences are however more
 * than two characters, and start with the characters ESC and [ (left bracket).
 * This sequence is called CSI for Control Sequence Introducer (or Control
 * Sequence Initiator). The final character of these sequences is in the range
 * ASCII 64 to 126 (@ to ~).
 */

void ANSIModephrase::feed( char c ) {
	/* OK. We're escaped. Let's find out if we could have
	   a CSI entry, or a private-mode ANSI escape sequence */
	if ( c == '[' ) {
		/* OK. We've hit a CSI escape sequence. */
		ansi_next_state = &ansi_state_CSIValue;
	} else if ( c >= 64 && c <= 95 ) {
		/* We've hit a private-mode escape sequence */
		/* XXX: Implement the private-mode parsing */
		ansi_next_state = &ansi_state_InvalidState;
		throw new InvalidSequence();
	} else {
		/* We've hit garbage. */
		ansi_next_state = &ansi_state_InvalidState;
		throw new InvalidSequence();
	}
}

void ANSIModephrase::enter() {}
void ANSIModephrase::exit()  {}

ANSIModephrase ansi_state_ANSIModephrase;
{'fraction_non_alphanumeric': 0.11362856162032269, 'fraction_numerical': 0.01991074493649159, 'mean_word_length': 3.777049180327869, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '197608', 'n_tokens_mistral': 1012, 'n_tokens_neox': 905, 'n_words': 344}