View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0022006FPCPackagespublic2012-05-11 02:022014-03-06 10:23
ReporterMichalis Kamburelis 
Assigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
Platformi386OSDebian GNU/LinuxOS Version(testing)
Product VersionProduct Build 
Target Version2.6.1Fixed in Version2.7.1 
Summary0022006: fcl-passrc cannot parse program file with "program xxx;" declaration missing
DescriptionThe initial declaration "program xxx;" at the beginning of a program file is optional. But fcl-passrc fails to parse such program:

$ fpc program_simple.pas
# compiles Ok
$ fpc test_parser.lpr
$ ./test_parser program_simple.pas
An unhandled exception occurred at $0809673E:
EParserError: Expected "unit" at token "var" in file program_simple.pas at line 2 column 3

Attaching a patch that makes fcl-passrc assume it's a program (with missing "program xxx;" declaration) if it doesn't start with "program" or "unit" keyword. The output is then correct:

$ ./test_parser program_simple.pas
No interface section --- this is not a unit, this is a TPasProgram
Implementation item 0: Foo
Implementation item 1: Bar

The test_parser.lpr example code is also on http://wiki.freepascal.org/fcl-passrc [^] .
Tagspatch
FPCOldBugId
Fixed in Revision21910
Attached Filespatch file icon fcl-passrc_program_optional.patch [^] (1,800 bytes) 2012-05-11 02:02 [Show Content]
? file icon program_simple.pas [^] (62 bytes) 2012-05-11 02:03
? file icon test_parser.lpr [^] (2,046 bytes) 2012-05-11 02:03

- Relationships

-  Notes
(0061020)
Michael Van Canneyt (administrator)
2012-07-13 20:28

I solved the problem, but not with your patch.
I made the parser also much stricter. It now also accepts

program(input,output);

and no longer accepts things like

program something;
finalization
end.

- Issue History
Date Modified Username Field Change
2012-05-11 02:02 Michalis Kamburelis New Issue
2012-05-11 02:02 Michalis Kamburelis File Added: fcl-passrc_program_optional.patch
2012-05-11 02:03 Michalis Kamburelis Tag Attached: patch
2012-05-11 02:03 Michalis Kamburelis File Added: program_simple.pas
2012-05-11 02:03 Michalis Kamburelis File Added: test_parser.lpr
2012-07-13 20:26 Michael Van Canneyt Status new => assigned
2012-07-13 20:26 Michael Van Canneyt Assigned To => Michael Van Canneyt
2012-07-13 20:28 Michael Van Canneyt Fixed in Revision => 21910
2012-07-13 20:28 Michael Van Canneyt Status assigned => resolved
2012-07-13 20:28 Michael Van Canneyt Fixed in Version => 2.7.1
2012-07-13 20:28 Michael Van Canneyt Resolution open => fixed
2012-07-13 20:28 Michael Van Canneyt Note Added: 0061020
2012-07-13 20:28 Michael Van Canneyt Target Version => 2.6.1
2014-03-06 10:23 Michael Van Canneyt Status resolved => closed



MantisBT 1.2.12[^]
Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker