当前位置:网站首页>[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 }}边栏推荐
- 智慧之道(知行合一)
- [Jianzhi offer] 57 - ii Continuous positive sequence with sum s
- Hong Kong Polytechnic University | data efficient reinforcement learning and adaptive optimal perimeter control of network traffic dynamics
- NSQ source code installation and operation process
- [combinatorics] polynomial theorem (polynomial coefficients | full arrangement of multiple sets | number of schemes corresponding to the ball sub model | polynomial coefficient correlation identity)
- The way of wisdom (unity of knowledge and action)
- A survey of state of the art on visual slam
- Mysql database -dql
- RF Analyze Demo搭建 Step by Step
- Mysql 将逗号隔开的属性字段数据由列转行
猜你喜欢

Netease UI automation test exploration: airtest+poco

Cocos Creator 2. X automatic packaging (build + compile)

Aike AI frontier promotion (7.3)

Basis of target detection (IOU)

美团一面:为什么线程崩溃崩溃不会导致 JVM 崩溃

What material is sa537cl1? Sa537cl1 corresponds to the national standard material

CC2530 common registers for timer 1

CC2530 common registers for serial communication

Interviewer: how does the JVM allocate and recycle off heap memory

Threejs Part 2: vertex concept, geometry structure
随机推荐
为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”
MongoDB 的安装和基本操作
MySQL converts comma separated attribute field data from column to row
arduino-esp32:LVGL项目(一)整体框架
Add color to the interface automation test framework and realize the enterprise wechat test report
Kotlin学习快速入门(7)——扩展的妙用
RF Analyze Demo搭建 Step by Step
斑馬識別成狗,AI犯錯的原因被斯坦福找到了
Golang decorator mode and its use in NSQ
[combinatorics] polynomial theorem (polynomial coefficients | full arrangement of multiple sets | number of schemes corresponding to the ball sub model | polynomial coefficient correlation identity)
Mysql database -dql
[Jianzhi offer] 57 - ii Continuous positive sequence with sum s
PHP converts a one-dimensional array into a two-dimensional array
手机注册股票开户安全吗 开户需要钱吗
Cocos Creator 2. X automatic packaging (build + compile)
QT serial port UI design and solution to display Chinese garbled code
What is the maximum number of concurrent TCP connections for a server? 65535?
2022爱分析· 国央企数字化厂商全景报告
UCORE overview
Nifi from introduction to practice (nanny level tutorial) - flow