2005-06-22 11:20:32 -07:00
|
|
|
/*
|
|
|
|
* mooterm/mootermparser.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOOTERM_MOOTERMPARSER_H
|
|
|
|
#define MOOTERM_MOOTERMPARSER_H
|
|
|
|
|
2005-07-02 07:59:59 -07:00
|
|
|
#ifndef MOOTERM_COMPILATION
|
|
|
|
#error "Don't include this file"
|
|
|
|
#endif
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#include "mooterm/mooterm-private.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define MAX_PARAMS_LEN 4095
|
|
|
|
#define MAX_PARAMS_NUM 16
|
|
|
|
#define ERROR_CHAR '?'
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GString *old_data;
|
|
|
|
const guchar *data;
|
|
|
|
guint data_len;
|
|
|
|
} Input;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-02 07:59:59 -07:00
|
|
|
typedef struct {
|
|
|
|
gboolean old;
|
|
|
|
guint offset;
|
2005-07-10 19:54:58 -07:00
|
|
|
} InputIter;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PART_START,
|
|
|
|
PART_INTERMEDIATE,
|
|
|
|
PART_PARAMETERS,
|
|
|
|
PART_FINAL,
|
2005-07-14 23:37:09 -07:00
|
|
|
PART_DATA,
|
|
|
|
PART_ST,
|
2005-07-10 19:54:58 -07:00
|
|
|
PART_DONE
|
|
|
|
} SequencePartType;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LEX_ESCAPE,
|
2005-07-14 23:37:09 -07:00
|
|
|
LEX_CONTROL,
|
|
|
|
LEX_DCS
|
2005-07-10 19:54:58 -07:00
|
|
|
} LexType;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
|
|
|
typedef struct {
|
2005-07-10 19:54:58 -07:00
|
|
|
LexType lex;
|
|
|
|
SequencePartType part;
|
|
|
|
guint offset;
|
|
|
|
} Lexer;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
typedef enum {
|
2005-07-14 23:37:09 -07:00
|
|
|
INITIAL_ = 0,
|
|
|
|
ESCAPE_,
|
|
|
|
ESCAPE_INTERMEDIATE_,
|
|
|
|
DCS_,
|
|
|
|
CSI_,
|
|
|
|
OSC_,
|
|
|
|
PM_,
|
|
|
|
APC_,
|
|
|
|
ERROR_
|
2005-07-10 19:54:58 -07:00
|
|
|
} ParserState;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _MooTermParser {
|
|
|
|
MooTerm *term;
|
|
|
|
|
|
|
|
Input input;
|
|
|
|
gboolean save;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
InputIter current;
|
|
|
|
InputIter cmd_start;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
ParserState state;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
Lexer lex;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GString *character;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GString *intermediate;
|
|
|
|
GString *parameters;
|
|
|
|
GString *data;
|
|
|
|
guchar final;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GArray *numbers;
|
|
|
|
} MooTermParser;
|
2005-07-02 07:59:59 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
|
|
|
|
MooTermParser *moo_term_parser_new (MooTerm *term);
|
2005-06-22 11:20:32 -07:00
|
|
|
void moo_term_parser_free (MooTermParser *parser);
|
|
|
|
|
|
|
|
void moo_term_parser_parse (MooTermParser *parser,
|
|
|
|
const char *string,
|
2005-07-10 19:54:58 -07:00
|
|
|
guint len);
|
|
|
|
void moo_term_parser_reset (MooTermParser *parser);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-02 07:59:59 -07:00
|
|
|
int _moo_term_yylex (MooTermParser *parser);
|
|
|
|
void _moo_term_yyerror (MooTermParser *parser,
|
|
|
|
const char *string);
|
|
|
|
|
|
|
|
/* defined in generated mootermparser-yacc.c */
|
|
|
|
int _moo_term_yyparse (MooTermParser *parser);
|
|
|
|
|
2005-07-12 07:23:08 -07:00
|
|
|
char *_moo_term_current_ctl (MooTermParser *parser);
|
|
|
|
char *_moo_term_nice_char (guchar c);
|
2005-07-04 12:22:02 -07:00
|
|
|
char *_moo_term_nice_bytes (const char *string,
|
2005-07-02 07:59:59 -07:00
|
|
|
int len);
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* MOOTERM_MOOTERMPARSER_H */
|