LCOV - code coverage report
Current view: top level - src/terminal - parser.h (source / functions) Hit Total Coverage
Test: mosh-1.3.2 Code Coverage Lines: 7 7 100.0 %
Date: 2022-02-06 20:19:53 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :     Mosh: the mobile shell
       3             :     Copyright 2012 Keith Winstein
       4             : 
       5             :     This program is free software: you can redistribute it and/or modify
       6             :     it under the terms of the GNU General Public License as published by
       7             :     the Free Software Foundation, either version 3 of the License, or
       8             :     (at your option) any later version.
       9             : 
      10             :     This program is distributed in the hope that it will be useful,
      11             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :     GNU General Public License for more details.
      14             : 
      15             :     You should have received a copy of the GNU General Public License
      16             :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      17             : 
      18             :     In addition, as a special exception, the copyright holders give
      19             :     permission to link the code of portions of this program with the
      20             :     OpenSSL library under certain conditions as described in each
      21             :     individual source file, and distribute linked combinations including
      22             :     the two.
      23             : 
      24             :     You must obey the GNU General Public License in all respects for all
      25             :     of the code used other than OpenSSL. If you modify file(s) with this
      26             :     exception, you may extend this exception to your version of the
      27             :     file(s), but you are not obligated to do so. If you do not wish to do
      28             :     so, delete this exception statement from your version. If you delete
      29             :     this exception statement from all source files in the program, then
      30             :     also delete it here.
      31             : */
      32             : 
      33             : #ifndef PARSER_HPP
      34             : #define PARSER_HPP
      35             : 
      36             : /* Based on Paul Williams's parser,
      37             :    http://www.vt100.net/emu/dec_ansi_parser */
      38             : 
      39             : #include <wchar.h>
      40             : #include <string.h>
      41             : 
      42             : #include "parsertransition.h"
      43             : #include "parseraction.h"
      44             : #include "parserstate.h"
      45             : #include "parserstatefamily.h"
      46             : 
      47             : namespace Parser {
      48             :   extern const StateFamily family;
      49             : 
      50             :   class Parser {
      51             :   private:
      52             :     State const *state;
      53             : 
      54             :   public:
      55       12102 :     Parser() : state( &family.s_Ground ) {}
      56             : 
      57             :     Parser( const Parser &other );
      58             :     Parser & operator=( const Parser & );
      59             :     ~Parser() {}
      60             : 
      61             :     void input( wchar_t ch, Actions &actions );
      62             : 
      63       23153 :     void reset_input( void )
      64             :     {
      65       23153 :       state = &family.s_Ground;
      66             :     }
      67             : 
      68             :   };
      69             : 
      70             :   static const size_t BUF_SIZE = 8;
      71             : 
      72             :   class UTF8Parser {
      73             :   private:
      74             :     Parser parser;
      75             : 
      76             :     char buf[ BUF_SIZE ];
      77             :     size_t buf_len;
      78             : 
      79             :   public:
      80             :     UTF8Parser();
      81             : 
      82             :     void input( char c, Actions &actions );
      83             : 
      84       23153 :     void reset_input( void )
      85             :     {
      86       23153 :       parser.reset_input();
      87       23153 :       buf[0] = '\0';
      88       23153 :       buf_len = 0;
      89             :     }
      90             :   };
      91             : }
      92             : 
      93             : #endif

Generated by: LCOV version 1.14