Giter Club home page Giter Club logo

kml1's Introduction

=====[ 문법 ] =======================================
제공되는 파서가 정의하고 있는 문법은 과제의 프로그램을 전부 표현할 수 있는 문법입니다.
examples/test[0~2].k-을 참조하시면 쉽게 문법을 익히실 수 있을 것입니다.


=====[ 우선 순위 ]======================================
사용되는 기호들의 우선순위는 아래와 같습니다.

   +, -   (왼쪽)
   !, ||, && (왼쪽)
   :=     (오른쪽)
   while
   do
   if
   else   
   then
   ;      (왼쪽)

우선순위를 고려해야 되는 몇가지 일반적인 경우를 보여드리면 
다음과 같습니다.

  x := e ; cmd        =>    (x := e) ; cmd   ( := 이 ; 보다 우선 순위가 높기때문 )
  if e then cmd1 else cmd2; cmd3    =>    (if e then cmd1 else cmd2) ; cmd3 (if 가 ; 보다 우선순위가 높기 때문)

즉 if 의 바디로 sequence를 쓰고 싶으면 sequence를 
다음과 같이 괄호로 묶어 줘야 합니다.
  if e then (cmd1 ; cmd2) else cmd3 

방향성은 우선순위가 같은 경우에 적용이 됩니다.
예를 들어 방향성이 왼쪽인 + 는 
 
  x + y + 1    =>   (x + y) + 1 

이 되게 됩니다.

우선순위를 잘 모르겠을시에는 괄호를 쳐주는 것이 한가지 방편이 될 수 있습니다.


=====[ 컴파일 및 실행 방법 ]======================================
제공되는 k.ml 파일에는 숙제 구현 부분은 비워져 있습니다.  이 파일을 수정해서
interpreter를 완성하고 다음과 같이 컴파일 및 실행을 하면 됩니다.

[UNIX]
1. make
2. ./run examples/test1.k-

[WINDOWS]
1. make.bat 
2. run.exe examples\test1.k-


====[ 숙제 제출 방법 ] ===================================
구현이 끝난 후 k.ml 파일만 양식에 맞는 파일명으로 바꿔서 제출해주세요.



=====[ pretty-printer ] =================================
입력 프로그램을 간단히 화면에 출력시켜주는 pretty-printer가 
제공된 pp.ml 파일에 포함되어 있습니다.

사용법은 'run -pp test1.k-'를 실행하면 main.ml에서 run 함수를 불러서 
intepreter를 돌리는 것이 아니라 test1.k-를 파싱 해서 입력된 프로그램을 
화면에 출력해주고 마치게 됩니다.

이를 통해 파싱이 의도한 대로 되고 있는지 확인해 보실 수 있을 겁니다.


=====[ 주석 ]==========================================
K- 프로그램 안에서 (*  *) 로 주석을 사용할 수 있습니다.

  


--
17 이동권 [email protected]

kml1's People

Contributors

skkeem avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.