2008. 7. 22. 10:34
SKILL Language 1 Language/SKILL2008. 7. 22. 10:34
Syntax Summary
1. 주석
; Reminder of the line
/*
Several lines
*/
2. Data
Integer 5
floating point 5.3
text string "this is text"
list ( 1 "two" 3 4 )
boolean t ; true
f ; false
3. Variable : [a-zA-Z_][a-zA-Z0-9_?]*, Case sensitive, Dynamic-linked, Must initialize
line_Count1
x=5 ; assignment
x ; retrieval
4. Funciton Call
strcat( "Good" "day" ) 혹은 ( strcat "Good" "day" )
한 줄에 여러 개의 Function Call을 할 수 있으나 제일 마지막 함수의 값만 return된다.
반대로 한 함수를 여러 line에 걸쳐 작성할 수도 있다.
괄호 모두 닫기 : ]
5. Operators
4+5*6 혹은 plus( 4 times(5 6) )
6. List
Creating: '( 1 2 3 ) 혹 list( 1 2 3) 혹은 숫자:숫자 ( list(300:400 500:450) O.K, '(300:400 500:450) NO)
앞에 element 하나 추가 construct fn: L = cons(1 L) cons('(1 2) '(3 4)) => ((1 2) 3 4 )
※ xcons()는 기능은 동일하고 인자 순서만 반대
뒤에 element 하나 추가 append1(l_list g_arg) append1('(1 2 3) 4) => (1 2 3 4)
두 List 합치기 append fn: B = append( A B ) append('(1 2) '(3 4)) => ( 1 2 3 4 )
nth째 element 추출: nth( n L )
자기 식구인지 확인: member( n L )
element 개수: member( L )
List에 Fiter: setof( x L oddp(x))
L = cons( car(L) cdr(L) )
bBox = '( LLx:LLy URx:URy )
car(bBox) = (LLx LLy), cadr(bBox) = (URx URy)
caar(bBox) = LLx, cadar(bBox) = LLy, caadr(bBox) = URx, cadadr(bBox) = URy
7. Query DataBase
~> : access the attribues of a database object (=getSGq())
~>? : return a list of attribute names
~>?? : returns list of name and values
8. Skill Funciton
{ } : group Skill statements into a single statement. Return value of the last statement.
let() : local variable생성. nil로 초기화되며 인수는 必 있어야 함
procedure( function_name( arguments )
let( local_variable )
Function body
마지막 실행문의 값이 return value
) ; let
) ; procedure
Optional function parameters: procedure( TrOffsetBBox( bBox @optional (dx 0) (dy 0))
Keyword function parameters: procedure( TrOffsetBBox( bBox @key (dx 0) (dy 0))
Variable parameters: procedure( TrCreatePath( @rest points )
Function Re-define방지: sstatus( writeProtect t) 해제: sstatus( writeProtect nil)
9. Flow of Control
Branching - Binary Branching: if, when, unless
Multiway Branching: case, cond
Arbitrary exit: prog ~ return
if( cond == value then when( cond unless( cond == value
expr1 expr .. expr...
else ) ; when ) ; unless
expr2
) ;if
case( shapeType cond(
( "rect" ( condition1 expr11 expr12 ... )
expr1 ( condition2 expr21 expr22 ... )
) ( condition3 expr31 expr32 ... )
( ( "line" "label" ) ( t exprN1 exprN2 ... )
expr2 ) ;cond
)
( t
always_expr1
)
) ;case
Iteration - Numerical range: for
List of values: foreach
While a condition is non-nil: while
for( i 1 5 <- local variable, 1씩 증가 foreach( shapeType shapeTypeList
sum = sum + i ... case( shapeType
) ; for <- t를 return ( "rect" ++rectCount )
( "line" ++lineCount )
prog( () ( t ++miscCount )
for( i 0 10 ) ;case
when( oddp(i) ) ;foreach <- shapeType List를 return
return(i)
) ;when
) ;for
) ;prog
while( gets( nextLine inPort )
expr1
) ;while
prog와 return함수: Block탈출시 쌍으로 사용함
prog( ( local variables )
condition return( value )
) ; prog
10. File I/O
Write file: outfile/print, println, fprintf/close
outPort = outfile( "file_name" ) => port return. if fail, nil return
println( value outPort ) 혹은 fprintf( outPort "%s" variable )
close( outPort )
Read file: infile/gets, fscanf/close
inPort = infile( "file_name" )
gets( nextLine inPort ) => EOF이면 nil 혹은 fscanf( inPort "%s" variable )
close( inPort )
Text file 보기
view(
"~/CDS.log" ; Path and file name
nil ; Default location
"Log File" ; Window title
t ; Auto-update
) => Window:5
1. 주석
; Reminder of the line
/*
Several lines
*/
2. Data
Integer 5
floating point 5.3
text string "this is text"
list ( 1 "two" 3 4 )
boolean t ; true
f ; false
3. Variable : [a-zA-Z_][a-zA-Z0-9_?]*, Case sensitive, Dynamic-linked, Must initialize
line_Count1
x=5 ; assignment
x ; retrieval
4. Funciton Call
strcat( "Good" "day" ) 혹은 ( strcat "Good" "day" )
한 줄에 여러 개의 Function Call을 할 수 있으나 제일 마지막 함수의 값만 return된다.
반대로 한 함수를 여러 line에 걸쳐 작성할 수도 있다.
괄호 모두 닫기 : ]
5. Operators
4+5*6 혹은 plus( 4 times(5 6) )
6. List
Creating: '( 1 2 3 ) 혹 list( 1 2 3) 혹은 숫자:숫자 ( list(300:400 500:450) O.K, '(300:400 500:450) NO)
앞에 element 하나 추가 construct fn: L = cons(1 L) cons('(1 2) '(3 4)) => ((1 2) 3 4 )
※ xcons()는 기능은 동일하고 인자 순서만 반대
뒤에 element 하나 추가 append1(l_list g_arg) append1('(1 2 3) 4) => (1 2 3 4)
두 List 합치기 append fn: B = append( A B ) append('(1 2) '(3 4)) => ( 1 2 3 4 )
nth째 element 추출: nth( n L )
자기 식구인지 확인: member( n L )
element 개수: member( L )
List에 Fiter: setof( x L oddp(x))
L = cons( car(L) cdr(L) )
bBox = '( LLx:LLy URx:URy )
car(bBox) = (LLx LLy), cadr(bBox) = (URx URy)
caar(bBox) = LLx, cadar(bBox) = LLy, caadr(bBox) = URx, cadadr(bBox) = URy
7. Query DataBase
~> : access the attribues of a database object (=getSGq())
~>? : return a list of attribute names
~>?? : returns list of name and values
8. Skill Funciton
{ } : group Skill statements into a single statement. Return value of the last statement.
let() : local variable생성. nil로 초기화되며 인수는 必 있어야 함
procedure( function_name( arguments )
let( local_variable )
Function body
마지막 실행문의 값이 return value
) ; let
) ; procedure
Optional function parameters: procedure( TrOffsetBBox( bBox @optional (dx 0) (dy 0))
Keyword function parameters: procedure( TrOffsetBBox( bBox @key (dx 0) (dy 0))
Variable parameters: procedure( TrCreatePath( @rest points )
Function Re-define방지: sstatus( writeProtect t) 해제: sstatus( writeProtect nil)
9. Flow of Control
Branching - Binary Branching: if, when, unless
Multiway Branching: case, cond
Arbitrary exit: prog ~ return
if( cond == value then when( cond unless( cond == value
expr1 expr .. expr...
else ) ; when ) ; unless
expr2
) ;if
case( shapeType cond(
( "rect" ( condition1 expr11 expr12 ... )
expr1 ( condition2 expr21 expr22 ... )
) ( condition3 expr31 expr32 ... )
( ( "line" "label" ) ( t exprN1 exprN2 ... )
expr2 ) ;cond
)
( t
always_expr1
)
) ;case
Iteration - Numerical range: for
List of values: foreach
While a condition is non-nil: while
for( i 1 5 <- local variable, 1씩 증가 foreach( shapeType shapeTypeList
sum = sum + i ... case( shapeType
) ; for <- t를 return ( "rect" ++rectCount )
( "line" ++lineCount )
prog( () ( t ++miscCount )
for( i 0 10 ) ;case
when( oddp(i) ) ;foreach <- shapeType List를 return
return(i)
) ;when
) ;for
) ;prog
while( gets( nextLine inPort )
expr1
) ;while
prog와 return함수: Block탈출시 쌍으로 사용함
prog( ( local variables )
condition return( value )
) ; prog
10. File I/O
Write file: outfile/print, println, fprintf/close
outPort = outfile( "file_name" ) => port return. if fail, nil return
println( value outPort ) 혹은 fprintf( outPort "%s" variable )
close( outPort )
Read file: infile/gets, fscanf/close
inPort = infile( "file_name" )
gets( nextLine inPort ) => EOF이면 nil 혹은 fscanf( inPort "%s" variable )
close( inPort )
Text file 보기
view(
"~/CDS.log" ; Path and file name
nil ; Default location
"Log File" ; Window title
t ; Auto-update
) => Window:5