当前位置:网站首页>[2. Basics of Delphi grammar] 1 Identifiers and reserved words
[2. Basics of Delphi grammar] 1 Identifiers and reserved words
2022-07-03 16:47:00 【Janeb1018】
1. Identifiers and reserved words
stay Object Pascal in , Symbols consist of one or more characters , Is the most basic language element .
1.1 identifier
The identifier is ObjectPascal Variables in language 、 Constant 、 type 、 The process 、 function 、 Method 、 Name of unit, etc .
Standard Identifier
The standard identifier is ObjectPascal Language is pre assigned to standard functions 、 Standard process 、 Standard type 、 Standard constant 、 Identifiers used in standard documents .
Standard constant Such as :False、True、Maxint etc.
Standard type Such as :Boolean、Char、Real etc.
Standard functions Such as :Sin、Cos、Abs、Arctan etc.
Standard process Such as :Dispose、Get、New、Pack、Put etc.
Standard document Such as :Input、Output etc.
Custom identifier
Custom identifiers are based on the needs of program design , Self defined constants 、 Variable 、 type 、 function 、 Name of process, etc . stay Object Pascal Rules for defining identifiers in :
1. Identifiers are case insensitive 2. Identifiers can only start with letters or underscores 3. Identifier can be any length , But only before 255 Characters are valid 4. No space is allowed between identifiers 5. Not allowed Object Pascal Reserved word as identifier
Qualified identifier
stay Object Pascal Multiple units can be referenced in , And the global variables in each unit 、 function 、 Process, etc. may have the same name , therefore , When referenced in the program, you need to use qualified identifiers to distinguish . Such as :
Var Y: real; Y := System.cos(pi);
In code System Is the qualified identifier , limit cos The identifier is System The identifier declared in the unit .
1.2 Reserved words
Reserved words are specified by the system , Words with special meanings and uses , It cannot be redefined in programming .Object Pascal It defines 65 A reserved word :
Reserved words | |||||
---|---|---|---|---|---|
and | array | as | asm | begin | case |
class | Const | constructor | destructor | dispinterface | div |
do | downto | else | end | except | exports |
file | finalization | finally | for | function | goto |
if | implementation | in | inherite | initialization | inline |
is | interface | label | library | mod | Nil |
not | object | of | or | out | packed |
procedure | program | property | raise | record | repeat |
resourcestring | set | shl | shr | string | then |
threadvar | to | try | type | until | unit |
uses | var | while | with | xor |
1.3 Instruction character
Directives are also words with special meanings . Directives are only used in special program locations or meaningful program segments when context is associated , It can be redefined in other occasions .Object Pascal Specified in the 39 Directive characters :
Instruction character | |||||
---|---|---|---|---|---|
absolute | abstract | assembler | automated | cdecl | contains |
default | dispid | dynamic | export | external | far |
forward | implements | index | message | name | near |
nodefault | overload | override | package | pascal | private |
protected | public | published | read | readonly | register |
reintroduce | requires | resident | safecall | stdcall | stored |
virtual | write | writeonly |
1.4 Summary of reserved words and directives
Reserved word or directive | purpose |
---|---|
absolute | Instructions ( Variable ) |
abstract | Instructions ( Method ) |
and | Operator ( Boolean ) |
array | type |
as | Operator (RTTI) |
asm | sentence |
assembler | Backward compatibility ( assembly ) |
at | sentence ( exception handling ) |
automated | Access the category symbol ( class ) |
begin | Block marker |
case | sentence |
cdecl | Function call protocol |
class | type |
const | A statement or instruction ( Parameters ) |
constructor | Special methods |
contains | Operator ( aggregate ) |
default | Instructions ( attribute ) |
destructor | Special methods |
dispid | dispinterface Interface class symbol |
dispinterface | type |
div | Operator |
do | sentence |
downto | sentence (for) |
dynamic | Instructions ( Method ) |
else | sentence (if or case) |
end | Block marker |
except | sentence ( exception handling ) |
export | Backward compatibility ( class ) |
exports | Statement |
external | Instructions ( function ) |
far | Backward compatibility ( class ) |
file | type |
finalization | Unit structure |
finally | sentence ( exception handling ) |
for | sentence |
forward | Function instructions |
function | Statement |
goto | sentence |
if | sentence |
implementation | Unit structure |
implements | Instructions ( attribute ) |
in | Operator ( aggregate ) |
index | Instructions (dispinterface Interface ) |
inherited | sentence |
initialization | Unit structure |
inline | Backward compatibility ( see asm) |
interface | type |
is | Operator (RTTI) |
label | Statement |
library | Program structure |
message | Instructions ( Method ) |
mod | Operator ( mathematics ) |
name | Instructions ( function ) |
near | Backward compatibility ( class ) |
nil | The number |
nodefault | Instructions ( attribute ) |
not | Operator ( Boolean ) |
object | Backward compatibility ( class ) |
of | sentence (case) |
on | sentence ( exception handling ) |
or | Operator ( Boolean ) |
out | Instructions ( Parameters ) |
overload | Function instructions |
override | Function instructions |
package | Program structure ( Control pack ) |
packed | Instructions ( Record ) |
pascal | Function call protocol |
private | Access the category symbol (class) |
procedure | Statement |
program | Program structure |
property | Statement |
protected | Access the category symbol ( class ) |
public | Access the category symbol ( class ) |
published | Access the category symbol ( class ) |
raise | sentence ( exception handling ) |
read | Property class |
readonly | dispatch Interface class symbol |
record | type |
register | Function call protocol |
reintroduce | Function instructions |
repeat | sentence |
requires | Program structure ( Control pack ) |
resident | Instructions ( function ) |
resourcestring | type |
safecall | Function call protocol |
set | type |
shl | Operator ( mathematics ) |
shr | Operator ( mathematics ) |
stdcall | Function call protocol |
stored | Instructions ( attribute ) |
string | type |
then | sentence (if) |
threadvar | Statement |
to | sentence (for) |
try | sentence ( exception handling ) |
type | Statement |
unit | Unit structure |
until | sentence |
uses | Unit structure |
var | Statement |
virtual | Instructions ( Method ) |
while | sentence |
with | sentence |
write | Property class |
writeonly | dispatch Interface class symbol |
xor | Operator ( Boolean ) |
1.5 notes
Object Pascal Notes in language :
Combination symbol { And } Use in pairs to indicate that the included content is annotation content .
Combination symbol (* And *) Use in pairs to indicate that the included content is annotation content .
Symbol // The single use of indicates that the content after the symbol in the line is the annotation content .
for example :
{ Curly bracket comment } (* parentheses / Asterisk notes *) //C++ Style notes
Be careful , Do not nest notes of the same type . Although different types of annotations are syntactically legitimate , But this is not recommended . for example :
{(* It's legal *)} (*{ It's legal }*) (*(* It's illegal *)*) { { It's illegal }}
边栏推荐
- Kotlin学习快速入门(7)——扩展的妙用
- Pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs
- Mysql database DDL and DML
- To resist 7-Zip, list "three sins"? Netizen: "is the third key?"
- Add color to the interface automation test framework and realize the enterprise wechat test report
- arduino-esp32:LVGL项目(一)整体框架
- CC2530 common registers for crystal oscillator settings
- 【剑指 Offer 】64. 求1+2+…+n
- 8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
- 网络安全web渗透技术
猜你喜欢
What is the difference between 14Cr1MoR container plate and 14Cr1MoR (H)? Chemical composition and performance analysis of 14Cr1MoR
Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
arduino-esp32:LVGL项目(一)整体框架
NLP four paradigms: paradigm 1: fully supervised learning in the era of non neural networks (Feature Engineering); Paradigm 2: fully supervised learning based on neural network (Architecture Engineeri
utfwry. Dat PHP, about ThinkPHP's method of IP location using utfwry address Library
爱可可AI前沿推介(7.3)
Explore Netease's large-scale automated testing solutions see here see here
Network security web penetration technology
Kotlin学习快速入门(7)——扩展的妙用
为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”
随机推荐
Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
Nifi from introduction to practice (nanny level tutorial) - flow
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
【剑指 Offer 】64. 求1+2+…+n
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
一台服务器最大并发 tcp 连接数多少?65535?
线程池执行定时任务
Custom plug-in construction and use of QT plug-in
Basis of target detection (IOU)
What is the material of sa302grc? American standard container plate sa302grc chemical composition
Processing strategy of message queue message loss and repeated message sending
Preventing/catching “IllegalArgumentException: parameter must be a descendant of this view” error
Overview of satellite navigation system
nifi从入门到实战(保姆级教程)——flow
网络安全web渗透技术
PHP CI (CodeIgniter) log level setting
Aike AI frontier promotion (7.3)
Construction practice camp - graduation summary of phase 6
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Mongodb installation and basic operation