搜索

pdf文档 Reference guide for Free Pascal, version 3.2.2

700.37 KB 268 页 0 下载 105 浏览 0 评论 0 收藏
语言 格式 评分
英语
.pdf
3
摘要
This document serves as a reference guide for the Pascal language implemented by the Free Pascal compiler. It details all Pascal constructs supported by Free Pascal and highlights differences from Turbo Pascal and Delphi implementations. Key features include support for function overloading, constant and variable parameters, default values, and the use of assembler code. The guide also covers exception handling and the integration of assembler within Pascal code. It emphasizes the use of specific compiler modes and directives for different language features.
AI总结
# Free Pascal 3.2.2 参考指南总结 ## 1. Pascal 标记 - **符号**:包括运算符、括号等。 - **注释**:支持单行注释(//)和多行注释(/* */)。 - **保留字**:分为Turbo Pascal保留字、Object Pascal保留字和修饰符。 - **标识符**:用于变量、函数、过程等。 - **数字**:包括整数、浮点数等。 ## 2. 常量 - **普通常量**:如`True`、`False`、`nil`等。 - **带类型常量**:如`const MyConst: Integer = 123;`。 - **资源字符串**:用于存储字符串资源,如`resourcestring S = 'Hello';`。 ## 3. 类型 ### 3.1 基数类型 - **整数类型**:包括`Integer`、`Shortint`、`Longint`、`Int64`、`Byte`、`Word`、`Cardinal`、`QWord`等,各有不同的范围和大小。 - **布尔类型**:`Boolean`,取值为`True`或`False`。 - **枚举类型**:定义一组枚举值,如`Type Color = (Red, Green, Blue);`。 - **子范围类型**:定义一个整数范围,如`Type Score = 0..100;`。 - **字符类型**:包括`Char`、`AnsiChar`、`WideChar`等。 ### 3.2 字符类型 - **`Char`或`AnsiChar`**:表示单个字符。 - **`WideChar`**:表示宽字符(Unicode)。 - **其他字符类型**:如`ShortString`、`LongString`等。 ## 4. 函数和过程 - **函数重载**:允许定义相同名称但参数列表不同的函数。 - **常数参数**:如`procedure MyProc(const A: Integer);`。 - **开放数组**:如`procedure MyProc(A: array of Integer);`。 - **可变参数**:支持类似C的可变参数,如`procedure MyProc(var A: array of Integer);`。 - **退出机制**:通过`Exit`关键字返回函数值或退出过程。 ## 5. 异常处理 - **异常定义**:通过`Exception`类或其子类定义异常。 - **异常处理**:使用`try...except...finally`结构。 - **异常抛出**:使用`raise`关键字抛出异常。 ## 6. 汇编支持 - **汇编语句**:在Pascal代码中嵌入汇编代码,如: ```pascal asm ; 汇编代码 end; ``` - **汇编过程和函数**:通过`Assembler`指令声明汇编过程和函数。 ## 7. 兼容性 - **Turbo Pascal/Delphi 模式**:Free Pascal支持通过编译器选项(如`-M`或`$MODE`指令)切换到Turbo Pascal或Delphi模式。 - **ISO 模式**:支持ISO Pascal标准。 ## 8. 数据类型限制 - **`Int64`和`QWord`**:在32位系统上,这些类型不是真正的序数类型,无法用于某些Pascal构造(如`for`循环)。 ## 9. 编译器模式 - **OBJFPC 模式**:支持Delphi语法扩展,如函数结果作为引用参数。 - **其他模式**:如`ISO`、`MACPAS`等,各有不同的语法和语义支持。 ## 10. 总结 Free Pascal参考指南详细描述了该语言的语法和数据类型,重点介绍了与Turbo Pascal和Delphi的兼容性差异。文档还提供了语法图和示例,帮助理解语言特性。对于开发者来说,掌握这些内容可以帮助更好地使用Free Pascal进行高效编程。
P1
P2
P3
P4
P5
P6
P7
下载文档到本地,方便使用
- 可预览页数已用完,剩余 261 页请下载阅读 -
文档评分
请文明评论,理性发言.