Giter VIP home page Giter VIP logo

urgent-lang's People

Contributors

senzhangai avatar thautwarm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

senzhangai

urgent-lang's Issues

narrow the exception types and pretty print exceptions

Currently, the exceptions are not well-rendered, and I just collect the error here,

self._loc = expr.loc
try:
ret = self.dispatches[expr.__class__](self, expr)
return ret
except Report:
,
and do some basic formatting at
except Report as e:
if debug:
traceback.print_exc(limit=tracing_limit)
.

Also, many exceptions raised when compiling are just this simple, without a proper exception type specified:

raise Exception("redefinition of operator properties")

To narrow the exception types, we might create a new module called excs, and make some new exception types in this module, for raising during compilation. The existing exception types might be migrated to excs module.

To pretty print the exceptions, we might create a method in excs to well render the exception to string message.

highlighting

随便写写, 能用就行.

%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
  - ugt
scope: source.urgent

contexts:
  # The prototype context is prepended to all contexts but those setting
  # meta_include_prototype: false.
  prototype:
    - include: comments

  main:
    # The main context is the initial starting point of our syntax.
    # Include other contexts from here (or specify them directly).
    - include: keywords
    - include: numbers
    - include: strings
    - include: operators
    - include: cases

  keywords:
    # Keywords are if, else for and while.
    # Note that blackslashes don't need to be escaped within single quoted
    # strings in YAML. When using single quoted strings, only single quotes
    # need to be escaped: this is done by using two single quotes next to each
    # other.
    - match: '\b(data|match|rec|True|False|and|or|else|for|while|let|def|module|in|infixl|infixr|open|do)\b'
      scope: keyword.control.example-c


  cases:
    - match: '\b[A-Z][a-zA-Z_0-9]*\b'
      scope: entity.name.class

  numbers:
    - match: '\b(-)?[0-9.]+\b'
      scope: constant.numeric.example-c

  operators:
    - match: '->|=>|and|or'
      scope: keyword.operator.haskell

  strings:
    # Strings begin and end with quotes, and use backslashes as an escape
    # character.
    - match: '"'
      scope: punctuation.definition.string.begin.example-c
      push: inside_string

  inside_string:
    - meta_include_prototype: false
    - meta_scope: string.quoted.double.example-c
    - match: '\.'
      scope: constant.character.escape.example-c
    - match: '"'
      scope: punctuation.definition.string.end.example-c
      pop: true

  comments:
    # Comments begin with a '//' and finish at the end of the line.
    - match: '//'
      scope: punctuation.definition.comment.example-c
      push:
        # This is an anonymous context push for brevity.
        - meta_scope: comment.line.double-slash.example-c
        - match: $\n?
          pop: true

import Hello failed

I tried to run examples in README.md, but got an error. :(

Environment

Python version: 3.7

install urgent-lang by:

pip3 install urgent
pip3 install prompt_toolkit

urgent-lang version:

$ pip3 show urgent
Name: urgent
Version: 0.1.1
Summary: UNKNOWN
Home-page: https://github.com/RemuLang/urgent
Author: thautawarm
Author-email: [email protected]
License: mit
Location: /usr/local/lib/python3.7/site-packages
Requires: toml, remu-operator, argser, rbnf-rts, sijuiacion-lang
Required-by:

Error message

# Sen @ Sen in ~/github/urgent-lang on git:master x [15:38:45]
$ ls
LICENSE            build-parser.sh    dev3.py            test               urgent_stmt.exrbnf
README.md          cli.py             hello.ugt          urgent
base               dev.py             mininal_sijuiacion urgent.exrbnf
bootstrap.toml     dev2.py            setup.py           urgent.rlex

# Sen @ Sen in ~/github/urgent-lang on git:master x [15:38:47]
$ ugt repl
Urgent> import Hello
Traceback (most recent call last):
  File "/usr/local/bin/ugt", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/urgent/cli.py", line 73, in main
    subs.parse()
  File "/usr/local/lib/python3.7/site-packages/argser/parse_func.py", line 136, in parse
    return self.functions[name](**data)
  File "/usr/local/lib/python3.7/site-packages/urgent/repl1s.py", line 59, in repl
    print('=>', eval(code, ctx, ctx))
  File "import Hello", line 11, in <repl>
  File "base", line 1, in tailcall
TypeError: cannot unpack non-iterable module object

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.