Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2003-03

h2pas and #warning

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jeff Pohlmeyer

If I feed this into h2pas:

#error "This is an error"
#warning "This is a warning"
#define nothing 0

I get an error message:

Illegal character in line 2
"#warning "This is a warning""
at line 2 error : syntax error

and the output is:

  {$error "This is an error"}
  (* error
  #warning "This is a warning"
  (* error
  #warning "This is a warning"
  in define line 3 *)

For some reason, h2pas is writing the message twice, and not properly closing the comment for the first message. ( This also causes it to skip the #define on line 3 )

Here is a simple patch so it will recognize the #warning, and keep it from falling through on unknown directives...

[PATCH]

--- scan.l.old	Wed Feb 26 12:45:31 2003
+++ scan.l.new	Sun Mar  2 01:25:26 2003
@@ -584,6 +584,12 @@
                            writeln(outfile,'}');
                            flush(outfile);
                         end;
+"#"[ \t]*"warning"      begin
+                           write(outfile,'{$warning');
+                           copy_until_eol;
+                           writeln(outfile,'}');
+                           flush(outfile);
+                        end;
 "#"[ \t]*"include"      begin
                            write(outfile,'{$include');
                            copy_until_eol;
@@ -630,6 +636,20 @@
                            in_define:=true;
                            in_space_define:=1;
                            return(DEFINE);
+                        end;
+"#"                     begin
+                           writeln('at line ',yylineno,
+                           ' error : unknown directive');
+                           if not stripinfo then
+                            begin
+                              write(outfile,'(** unknown directive: #');
+                              copy_until_eol;
+                              writeln(outfile,' *)');
+                              flush(outfile);
+                            end
+                           else
+                            skip_until_eol;
+                           block_type:=bt_no;
                         end;
 "char"                  return(_CHAR);
 "union"                 return(UNION);

[/PATCH]

Now the output is:

  {$error "This is an error"}
  {$warning "This is a warning"}
  const
     nothing = 0;

This will also let it handle things like:
#strange "This is something strange"

Prints the message:
at line 3 error : unknown directive

And becomes:
  (** unknown directive: #strange "This is something strange" *)

__________________________________________________ Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/

Reply by email

Marco van de Voort
to Gene Buckle
Show quoted text 7 lines
Why would a function definition like this: Function Test(value : set of foo) : string; cause the compiler to pitch an invalid type error? The set is defined correctly.

You can't use composed types (string[xx], procedure types, sets etc) like this.

That is standard Pascal syntax, not the Borland derived syntaxes that FPC uses.

Use

type valuetype: set of foo;
function Test(value:valuetype):string;

Reply by email