Code Monkey home page Code Monkey logo

lollang's Introduction

롤랭 컴파일러

Hits Language grade: Python License: MIT Lines of code GitHub last commit Total alerts GitHub Workflow Status

GitHub Repo stars

lol-lang icon

롤의 각종 유행어(?)들을 조합해 만들었습니다.

고급언어(롤랭)을 저급언어(파이썬)으로 번역하는 컴파일러입니다.

변수명을 챔피언 이름으로 하면 재밌습니다.

확장자는 .lola입니다.

기능 추가/개선 사항, 버그 등은 이슈에 남겨주세요.

롤랭을 웹에서 만나보세요!

Created by wonjinYi (repo)

사용법

python main.py --file <lo파일 경로> --out <목적 파이썬 파일 경로(기본 : out.py)>

lollang's People

Contributors

riroan avatar

Stargazers

Jay avatar Joon Hwan 김준환 avatar Yoonwoo avatar  avatar jinho park avatar Hojin Jang avatar Wonjin Lee avatar

Watchers

 avatar  avatar

Forkers

wonjinyi

lollang's Issues

ZeroDivisionError가 컴파일에러가 아닌 런타임에러로 처리됩니다.

요약

ZeroDivisionError가 컴파일에러가 아닌 런타임에러로서 발생합니다.

의문

zero division을 lollang에서 컴파일에러로 처리하기를 원하시는지 궁금합니다.
(이 에러를 컴파일단에서 검사하는 코드가 커밋에 누락되었는지?)

배경

우리 잘해보죠
아트록스님 캐리좀 ㅠㅏㄴㅠㅡㅠㄹ
팀차이 ㅈㅈ

위 코드는 ZeroDivisionError 가 발생하는 lollang코드입니다.
현재 해당 에러에 대한 처리는 compiler.py의 두 곳에서 하고 있습니다.

  • 380행 : def compileFile(self, path, outPath = "out.py"):
except ZeroDivisionError:
            print(f"{self.currentLine}번째 적이 전장의 화신입니다!!")
  • 392행 : def run(self, path = "out.py"):
except:
    print("소환사 한명이 게임을 종료했습니다.")

문제상황

f"{self.currentLine}번째 적이 전장의 화신입니다!!" 오류메시지가 출력될 것이 예상되었으나,
"소환사 한명이 게임을 종료했습니다." 오류메시지가 출력되었습니다.

즉, 380행 컴파일에러(except ZeroDivisionError)로는 잡지 못하고,
392행 런타임에러(except)로 잡히는 것을 확인하였습니다.

또한, compiler.py내에서 zero division관련 에러를 발생시키는 부분을 발견하지 못했습니다.

맺음 : 런타임에러로 처리하는 경우

만약 zero division을 런타임에러로 처리하기로 결정한 경우
compiler.py의 367~392행을 아래와 같이 변경할 것을 건의드립니다.

def compileFile(self, path, outPath = "out.py"):
    try:
        with open(path, "r", encoding="utf-8") as file:
            codelines = [i.strip() for i in file.readlines()]
            self.compile(codelines)
    except TypeError:
        print(f"{self.currentLine}번째 적이 학살중입니다!!")
    except SyntaxError:
        print(f"{self.currentLine}번째 적은 전설적입니다!!")
    except ValueError:
        print(f"{self.currentLine}번째 적을 도저히 막을 수 없습니다!!")
    except KeyError:
        print(f"{self.currentLine}번째 적이 전장을 지배하고 있습니다!!")
    except FileNotFoundError:
        print("서버에 연결할 수 없습니다.")
    else:
        self.save(outPath)
        self.run(outPath)

def run(self, path = "out.py"):
    try:
        exec(open(path).read())
    except ZeroDivisionError:      ####################  ZeroDivisionError 처리 여기로 이동
            print("적이 전장의 화신입니다!!")
    except Exception as ex:
        print("소환사 한명이 게임을 종료했습니다.")

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.