"Fossies" - the Fresh Open Source Software Archive

Member "seed7/lib/comp/ut8_act.s7i" (24 Jun 2014, 4465 Bytes) of package /linux/misc/seed7_05_20210223.tgz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 (********************************************************************)
    3 (*                                                                  *)
    4 (*  ut8_act.s7i   Generate code for actions of the UTF-8 file type. *)
    5 (*  Copyright (C) 1990 - 1994, 2004 - 2014  Thomas Mertes           *)
    6 (*                                                                  *)
    7 (*  This file is part of the Seed7 compiler.                        *)
    8 (*                                                                  *)
    9 (*  This program is free software; you can redistribute it and/or   *)
   10 (*  modify it under the terms of the GNU General Public License as  *)
   11 (*  published by the Free Software Foundation; either version 2 of  *)
   12 (*  the License, or (at your option) any later version.             *)
   13 (*                                                                  *)
   14 (*  This program is distributed in the hope that it will be useful, *)
   15 (*  but WITHOUT ANY WARRANTY; without even the implied warranty of  *)
   16 (*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *)
   17 (*  GNU General Public License for more details.                    *)
   18 (*                                                                  *)
   19 (*  You should have received a copy of the GNU General Public       *)
   20 (*  License along with this program; if not, write to the           *)
   21 (*  Free Software Foundation, Inc., 51 Franklin Street,             *)
   22 (*  Fifth Floor, Boston, MA  02110-1301, USA.                       *)
   23 (*                                                                  *)
   24 (********************************************************************)
   25 
   26 
   27 const ACTION: UT8_GETC       is action "UT8_GETC";
   28 const ACTION: UT8_GETS       is action "UT8_GETS";
   29 const ACTION: UT8_LINE_READ  is action "UT8_LINE_READ";
   30 const ACTION: UT8_SEEK       is action "UT8_SEEK";
   31 const ACTION: UT8_WORD_READ  is action "UT8_WORD_READ";
   32 const ACTION: UT8_WRITE      is action "UT8_WRITE";
   33 
   34 
   35 const proc: ut8_prototypes (inout file: c_prog) is func
   36 
   37   begin
   38     declareExtern(c_prog, "charType    ut8Getc (fileType);");
   39     declareExtern(c_prog, "striType    ut8Gets (fileType, intType);");
   40     declareExtern(c_prog, "striType    ut8LineRead (fileType, charType *);");
   41     declareExtern(c_prog, "void        ut8Seek (fileType, intType);");
   42     declareExtern(c_prog, "striType    ut8WordRead (fileType, charType *);");
   43     declareExtern(c_prog, "void        ut8Write (fileType, const const_striType);");
   44   end func;
   45 
   46 
   47 const proc: process (UT8_GETC, in reference: function,
   48     in ref_list: params, inout expr_type: c_expr) is func
   49 
   50   begin
   51     c_expr.expr &:= "ut8Getc(";
   52     process_expr(params[1], c_expr);
   53     c_expr.expr &:= ")";
   54   end func;
   55 
   56 
   57 const proc: process (UT8_GETS, in reference: function,
   58     in ref_list: params, inout expr_type: c_expr) is func
   59 
   60   begin
   61     prepare_stri_result(c_expr);
   62     c_expr.result_expr := "ut8Gets(";
   63     getStdParamToResultExpr(params[1], c_expr);
   64     c_expr.result_expr &:= ", ";
   65     getStdParamToResultExpr(params[2], c_expr);
   66     c_expr.result_expr &:= ")";
   67   end func;
   68 
   69 
   70 const proc: process (UT8_LINE_READ, in reference: function,
   71     in ref_list: params, inout expr_type: c_expr) is func
   72 
   73   begin
   74     prepare_stri_result(c_expr);
   75     c_expr.result_expr := "ut8LineRead(";
   76     getStdParamToResultExpr(params[1], c_expr);
   77     c_expr.result_expr &:= ", &(";
   78     getStdParamToResultExpr(params[2], c_expr);
   79     c_expr.result_expr &:= "))";
   80   end func;
   81 
   82 
   83 const proc: process (UT8_SEEK, in reference: function,
   84     in ref_list: params, inout expr_type: c_expr) is func
   85 
   86   begin
   87     c_expr.expr &:= "ut8Seek(";
   88     process_expr(params[1], c_expr);
   89     c_expr.expr &:= ", ";
   90     process_expr(params[2], c_expr);
   91     c_expr.expr &:= ");\n";
   92   end func;
   93 
   94 
   95 const proc: process (UT8_WORD_READ, in reference: function,
   96     in ref_list: params, inout expr_type: c_expr) is func
   97 
   98   begin
   99     prepare_stri_result(c_expr);
  100     c_expr.result_expr := "ut8WordRead(";
  101     getStdParamToResultExpr(params[1], c_expr);
  102     c_expr.result_expr &:= ", &(";
  103     getStdParamToResultExpr(params[2], c_expr);
  104     c_expr.result_expr &:= "))";
  105   end func;
  106 
  107 
  108 const proc: process (UT8_WRITE, in reference: function,
  109     in ref_list: params, inout expr_type: c_expr) is func
  110 
  111   begin
  112     setDiagnosticLine(c_expr);
  113     c_expr.expr &:= "ut8Write(";
  114     process_expr(params[1], c_expr);
  115     c_expr.expr &:= ", ";
  116     getAnyParamToExpr(params[2], c_expr);
  117     c_expr.expr &:= ");\n";
  118   end func;