[fpc-devel]h2pas: Patch for multi-line macros
Jeff Pohlmeyer
yetanothergeek at yahoo.com
Mon Feb 9 18:58:36 CET 2004
I see things like this a lot in C headers:
#define foo(a,b,c) \
( a + b + c )
But h2pas chokes when it sees the backslash:
Illegal character in line 1
"#define foo(a,b,c) \"
at line 1 error : syntax error
at line 2 error : syntax error
I think this will solve the problem:
[PATCH]
--- scan.l.OEM Wed Feb 26 12:45:31 2003
+++ scan.l.JKP Mon Feb 9 11:31:39 2004
@@ -149,6 +149,8 @@
const
in_define : boolean = false;
+ { True if define spans to the next line }
+ cont_line : boolean = false;
{ 1 after define; 2 after the ID to print the first separating space }
in_space_define : byte = 0;
arglevel : longint = 0;
@@ -668,12 +670,31 @@
\n begin
if in_define then
begin
- in_define:=false;
- in_space_define:=0;
- return(NEW_LINE);
+ in_space_define:=0;
+ if cont_line then
+ begin
+ cont_line:=false;
+ end
+ else
+ begin
+ in_define:=false;
+ return(NEW_LINE);
+ end;
end;
- end;
-. begin
+ end;
+\\$ begin
+ if in_define then
+ begin
+ cont_line:=true;
+ end
+ else
+ begin
+ writeln('Unexpected wrap of line ',yylineno);
+ writeln('"',yyline,'"');
+ return(256);
+ end;
+ end;
+. begin
writeln('Illegal character in line ',yylineno);
writeln('"',yyline,'"');
return(256);
[/PATCH]
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
More information about the fpc-devel
mailing list