Lexical Units Awk tokens Numeric constants String Constants
- Slides: 65
Lexical Units Awk โปรแกรมจะประกอบดวย กลมของอกขระทเรยกวา tokens ดงน - Numeric constants - String Constants - Keyword - Identifiers - Operators - Record and Fields - Comment - Token used for grouping
Lexical Units
Lexical Units Operators awk ม operator ใหใชไดดงน -Assignment operators - Arithmetic operators - relational operators - logical operator - Regular expression matching operators
Lexical Units Assignment operators
Lexical Units Arithmetic operators
Lexical Units Relational operators
Lexical Units Logical operators Regular expression matching operators
Primary expression Numeric Constant ตารางตวอยางคาของคาคงท
Primary expression String Constant ตารางตวอยางคาของคาคงท
Primary expression Variables มรปแบบดงน ตวแปรธรรมดา identifier[expression] ตวแปร array $Term ตวแปรอางถง identifiers ขอมล record
Primary expression Function awk ม function ใหใช String Function คอ arithmetic และ
Primary expression
Term Binary term อยในรป term binop : + , - , * , / , % Unary term อยในรป unop term unop : + , -
Term Incremented variable เปน term ทมรปแบบ คา ++ var -- var ++ var -- Parenthesized term var + 1 var - 1 var ใช ในการ group term และคาดงน ผลลพธ var = var + 1 var = var - 1
Expression มรปแบบดงน term. . . var asgnop expression concatenation of term ในรปแบบของ term 1 term 2 … คาของ string จะถกนำมา กนดงตว อยาง 1+2 3+4 = 37 concatenate
Expression Assignment expression รปแบบของ เมอ var asgnop expression asgnop : = , += , -= , *= , /= , %= รปแบบ var = op expression สมนยกบ var = var op expression เมอ op : = , + , _ , * , / , % และ asgnop เปน right association
Using awk เราจะอธบายการใชงาน ตามหวขอดงน awk - Input and output - Pattern - Action - Special feature
Using awk : Input and output : Input Sample input file : countries Russia Canada China USA Brazil Australia India Argentina Sudan Algeria 8650 3852 3692 3615 3286 2968 1269 1072 968 920 262 24 866 219 116 14 637 26 19 18 Asia North America South America Australia Asia South America Africa
Using awk : Input and output : Input : from command line เราสามารถเปลยนคาของ RS (Record separator) และ FS (Field separator) โดยการคำสงจาก command line ดงน awk -f awkprog RS = “; ” file 1 หรอ awk -F; -f awkprog file 1
Using awk Pattern pattern เปนการเลอกตดสนใจสำหรบการ กระทำ action โดยทเรานำ expression มาเปน pattern ดงน - Certain keyword - Arithmetic relational expression - Regular expression - Combination of these
Using awk : Action String concatenation เราสามารถนำ string มา concatenate กนไดโดยการเขยนให expression ตดกน { x = “hello” x = x “, world” print x } ผลลพธทไดคอ hello, world เชน
Using awk : Action Special variables
Using awk : Action Type ดงน type ของตวแปร ขน อยกบ context pop = $3 pop ม type เปน number country = $1 country ม type เปน string maxpop < $3 maxpop จะม type ตาม $3 โดยทวไปแลว type จะถก set จากการ assign คา v = expr ถา expr เปน arithmetic v เปน number ถา expr เปน concatenation v เปน string สำหรบการบงคบ type ทำไดคอ เปน number :
Using awk Special feature เราจะพดถง feature พเศษทเราสามารถใชใน awk ได - Bulit-In Function - Flow of control - Report generator - Cooperation with the shell - Multidimensional arrray
Using awk : Special feature Flow of control awk ม control statement ให ใชดง น - if. . . else - while - for
Using awk : Special feature : Flow of control If … Else มรปแบบดงน if (condition) statement 1 else statement 2 ตวอยาง { if (maxpop < $3) { maxpop = $3 country =$1 } } END { print country , maxpop }
Using awk : Special feature : Flow of control While มรปแบบดงน while (condition) statement ตวอยาง { } i=1 while (i <= NF) { print $i ++i }
Using awk : Special feature : Flow of control For มรปแบบดงน for (expr 1, expr 2, expr 3) statement 2 ตวอยาง { } for (i = 1; i <= NF; i++) print $i
Using awk : Special feature Report generator พจารณาจากตวอยาง Sunti Ying Nop Dare Ying Sunti Dare Nop awk nroff make dbx troff awk xdbx mail 9 8 7 5 2 1 5 3 ดงน
Using awk : Special feature Multidimensional array เราสามารถจำลองการ ทำงาน ของ multidimensional array ไดดงนคอ for ( i = 1 ; i <= 10 ; i++ ) for (j = 1 j <= 10 ; j++) mult[i “, ” j] = …
Reference Fortgang, Karen S. , UNIX System V (Programmer’s Guide), Prentice Hall, Inc. , Englewood Cliffs, NS 67632, 1987. Burk, Robin and Horvath, David B. , CCP, et al. , UNIX Unleashed Internet Edition, SAM Publishing , 1998
- Http protocol description
- Lexical problems of translation and lexical transformations
- Const name void
- Private string[]
- 3600000/24
- Awk compiler
- Awk gensub
- Mobile awk jugend und sport
- Ns2 commands
- Awk ns2
- Rails hadoop
- Awk filter
- Awk unix
- Awk regex
- Flex compiler tutorial
- Number of tokens
- Lexical analysis
- Longest match rule in lexical analysis
- Tokensn
- Tokens of trust
- Why does the poet wish to live with animals
- Usa test prep
- Marketo velocity scripting
- C++ tokens
- When units manufactured exceed units sold:
- Glabella botox
- Representation codes
- Numeric distribution nielsen
- Numeric data types in java
- Sqlite numeric type
- Hybridoma technology applications
- Numeric data types in python
- Nprs pain
- The domain of discrete numeric function is
- Numeric outline
- Straight numeric filing
- Sas numeric precision
- Numeric constant in qbasic
- Alpha numeric code
- Advantages of output devices
- Alphabet number code
- Numerical expression
- Numerical expression example
- Contoh infix
- Numeric indicator
- General alphabetic section of the numeric file
- Numeric integral
- Types of data representation in computer
- Clustering non numeric data
- Sifat variabel kategorik
- Simplified expression example
- Constants in scientific method
- Geminal and vicinal coupling constants
- Walter shewhart
- Constant of avogadro's law
- Equilibrium constant
- Constant integers
- Matlab str2int
- Stress strain curve toughness
- Spin-spin coupling examples
- Kp=kc(rt)^n
- Is time constant
- Crystal binding and elastic constants
- Named constants
- F_faaoo vk
- Constant in scientific method