본문 바로가기
프로그래밍/Pawn

Pawn 이란 무엇인가?

by 알용 2012. 4. 10.
반응형

머리말

보통 프로그래밍 언어라고 하면 C/C++, JAVA, VB, Python, HTML, Lua 등을 많이 이야기하는데
Pawn 이라고 하면 모르는 사람이 대부분이다.
잘 알려져 있지도 않고 활용하는 분야가 적은 것이 그 이유겠지만
Pawn 또한 다른 프로그래밍 언어와 같이 무시할 수 없는 프로그래밍 언어이다.
Pawn 카테고리에는 C언어 게시판과는 달리 강좌처럼 쭉 이어나가기 보다, 아주 기본적인 요소들만 설명하고
중학교 2학년 때부터 고등학교 1학년 때까지 약 3년동안 만들었던 수많은 스크립트 중의 일부를 포스팅할 계획이다.


Pawn은 C언어와 비슷한 문법을 사용하며 간단, 빠른 속도, 안전성 등의 장점을 가지고 있는 프로그래밍 언어이다.

Pawn으로 작성된 코드를 컴파일 할 수 있는 컴파일러로는 Pawno가 있으며 현재까지 릴리즈된 최신 버전은 4.0.4548 이다

Pawn을 이용하는 분야는 사실상 몇개 되지 않는데 내가 블로그에 올릴 분야는 SAMP Mode 제작이다.

SAMP란 San Andreas Multi Player 의 약자로써 GTA 시리즈 중의 하나인 San Anderas 멀티 서버를 의미하는데

서버를 구동하기 위해 필요한 요소 중 하나인 모드를 제작하기 위해 Pawn을 이용한다.

나는 블로그에 SAMP 상의 몇몇 모드메이커들을 위해 유용한 스크립트들을 포스팅하려고 한다.

따라서 1장,2장 정도만 기본적인 Pawn 내용으로 채워질 것이고 그 이후로는 스크립트들만 포스팅할 것이다.  

 

아래는 http://www.compuphase.com/pawn/pawn.htm 의 내용 중 일부를 가져온 것이다.
Pawn에 관한 자세한 정보인만큼 영어에 능한 분들은 한번쯤 읽어보길 바란다.

 

pawn

 
This product is made in the EU

Pawn's icon

An embedded scripting language

pawn is a simple, typeless, 32-bit extension language with a C-like syntax. A pawn "source" program is compiled to a binary file for optimal execution speed. The pawncompiler outputs P-code (or bytecode) that subsequently runs on an abstract machine. Execution speed, stability, simplicity and a small footprint were essential design criteria for both the language and the abstract machine.

At a glance


Current version4.0.4548 (2011-08-01)
View the history of recent changes.
DownloadsMicrosoft Windows: a self-extracting setup.
Linux & Unix: "autopackage" archive.
More downloads: ZIP files/tar-balls, pre-compiled binaries, auxiliary files, ....
LicenseApache License 2.0, plus an exception clause to explicitly permit static linking of the library to commercial applications.
InstallationMicrosoft Windows: download the self-extracting setup and run it. 
Linux: download the installation archive, extract the "autopackage" file (a shell script) and run it. 
All other operating systems: download a source archive as a compressed tar-ball or as a ZIP file and read the README.TXT file after unpacking. (See also the "Getting started" section below).
SupportThe the pawn forum is open to everyone. 
For support on a commercial basis, please contact us by e-mail. We can build speed-optimized versions of the abstract machine (also known as "virtual machine" or VM) or JITs, add special language constructs, port the product to different microcontrollers, and write native function libraries for particular tasks.
DocumentationAll documentation is in "Adobe Acrobat" format (PDF), readable with Adobe Acrobat and Ghostscript. The main two books are the "Language Guide" and the "Implementer's Guide". Several extension modules are documented separately.
Screen shotspawn is a compiler and an abstract machine. The compiler is a console utility (i.e. you run it in a "DOS box" or a terminal), and the abstract machine is basically a library. As such, there isn't really something like a representative a screen shot. I have tried a few anyway... 
Click on the pictures for a detailed view.

Terminal emulation

Terminal emulation under Windows, showing Unicode support

XML documentation

Documentation (XML) extracted from the source code comments and compiler reports

MP3 Controller

The "H0420" Programmable MP3 Controller uses pawn for scripting

Console debugger

pawn console debugger

Quincy IDE

The Quincy IDE with editor and debugger, adapted for pawn

Pawn GTK calculator

pawn calculator with a user interface in GTK, via gkt-server

ProjectsA list of projects and products that use pawn as a scripting language is on the page Where is pawn used?.

For any information not in this list, please browse through this page. Hopefully you will find what you are looking for.

section separator

Introduction

An introduction to the pawn language and abstract machine from a programmer's perspective was published in the October 1999 issue of Dr. Dobb's Journal —but at the time, the language was called Small. More verbose than the article, and more appropriate for non-expert programmers, is the manual. The manual contains a brief (tutorial) overview of the language, a language reference, programming notes on the abstract machine, casual notes about the why and how of many language features, and reference material.

  • pawn is a simple, C-like, language.
  • pawn is a robust language with a compiler that performs a maximum of static checks, and an abstract machine with (static) P-code verification and dynamic checks.
  • For porting purposes, pawn is written in ANSI C as much as possible; Big Endian versus Little Endian is handled.
  • To suit internationalization and localization, pawn supports Unicode/UCS-4 and UTF-8, as well as codepages. The compiler can convert source code entered in a particular codepage to Unicode; it also supports source code files in UTF-8 format.
  • pawn is quick (especially with Marc Peter's assembler implementation and/or his "just-in-time" compiler)
  • pawn is small. It has been fitted on an Atmel ATmega128 microcontroller, Philips LPC2138 and LPC2106 microcontrollers (ARM7TDMI core with 32 kiB RAM), as well as on a Texas Instrument's MSP430F1611 (MSP430 core with 10 kiB RAM and 48 kiB Flash ROM). Using code overlays that are loaded on demand, pawn is able to run large scripts in little memory.
  • Documenting the source code can be done with "documentation comments"; the pawn compiler extracts those comments, combines them with information it deduces from the source code and writes an XML file that is immediately viewable (and printable) with a web browser.
  • pawn supports states and automatons in the language, including state-local variables.
  • pawn is free and it is published under the Apache License 2.0, plus an exception clause to explicitly permit static linking of the library to commercial applications.
  • More features... see the separate "feature page"

Why pawn now that there is Java, Lua, REXX, and countless others? Well, when I needed a language toolkit whose executable code can be embedded in resource files or animation file formats, that had a good interface to native functions, that added little overhead to the main application and could run on platforms and microcontrollers with (very) little RAM, and that was pretty fast, I could not really find an existing toolkit that fitted my needs. See also a list of language features.

Unlike many languages, pawn is not intended to write complete full-scale applications in. pawn's purpose is to script the functionality provided by an application or by a device. It is in purpose similar to Microsoft's "Visual Basic for Applications", only quicker and smaller (and without the installation hassle).

pawn has been publicly available since 1998, and it has been steadily improving: more error checking, several bugs slashed, new features, and an increase in performance. There are still regular updates and patches: to fix bugs, to add features, or simply to enhance the ease-of-use.

A couple of other points are worth mentioning:

  • The current version of pawn is provided as is. Although I encourage you to send in (detailed) bug reports or requests for additions, I do not promise free support. 
    Fortunately, other individual programmer's are taking up pawn and modifying it for their needs. With their help (and perhaps yours as well), pawn will continue to evolve.
  • The pawn toolkit consists of a compiler and an abstract machine (or "virtual machine"). In the default setup, the abstract machine is embedded in an application (for easy interfacing with the application's objects and for best performance), while the compiler is a separate executable that the application launches as an external process.
       When embedding the compiler into an application, please note that the main function of the compiler, pc_compile(), is not re-entrant. In other words, compile only one script at a time.




 

반응형