Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 22:57
    erezsh commented #316
  • Jan 31 2019 22:57
    erezsh commented #316
  • Jan 31 2019 22:42
    excitoon commented #316
  • Jan 31 2019 22:41
    excitoon commented #316
  • Jan 31 2019 22:29

    erezsh on master

    Docs: Fixup (compare)

  • Jan 31 2019 22:28
    erezsh commented #316
  • Jan 31 2019 22:28

    erezsh on master

    BUGFIX: Indenter was in corrupt… Docs: Added instructions on how… (compare)

  • Jan 31 2019 22:05
    erezsh commented #309
  • Jan 31 2019 22:04
    erezsh commented #309
  • Jan 31 2019 22:03

    erezsh on master

    BUGFIX: Fixed common.ESCAPED_ST… (compare)

  • Jan 31 2019 19:33
    excitoon edited #316
  • Jan 31 2019 19:33
    excitoon edited #316
  • Jan 31 2019 19:32
    excitoon opened #316
  • Jan 31 2019 15:24
    chaosite commented #314
  • Jan 31 2019 02:31
    Vesuvium commented #314
  • Jan 30 2019 19:24
    Agitolyev starred lark-parser/lark
  • Jan 30 2019 07:36
    YaakovTooth starred lark-parser/lark
  • Jan 29 2019 05:59
    macdavid313 starred lark-parser/lark
  • Jan 29 2019 02:36
    ibrahimsharaf starred lark-parser/lark
  • Jan 29 2019 02:07
    fuyunliu starred lark-parser/lark
Erez Shinan
@erezsh
I don't think I'll be able to teach LALR or Earley in a short article. There's a bit of complexity in there
ThatXliner
@ThatXliner
Oh
ok then

The best dev guide is probably the code :)

ye

Erez Shinan
@erezsh
I'll try to answer any specific question
But explaining everything.. that's a big job
ThatXliner
@ThatXliner
lol ok
MegaIng
@MegaIng
That seems to be quite mature.
ThatXliner
@ThatXliner
?
Stjepan Jakovac
@sJakovac
q, how do I use character / inside regex literal
decorator-factory
@decorator-factory
@sJakovac You escape it with \:
FRACTION: /[0-9]+\/[0-9]+/
ThatXliner
@ThatXliner
Xkcd backslashes comic
decorator-factory
@decorator-factory
@erezsh Hi, if you remember, I was working on a tutorial project a while ago, I kind of forgotten about it (sorry, I'll continue working on it soon!).
In the meanwhile I made a similar project (lispy language), but a more visual one -- it's a markup language that compiler down to HTML. I'm working on extensively documenting the code, and it has a pretty robust usage documentation (written in itself, of course): https://decorator-factory.github.io/python-fnl/ , so maybe it could be a good example of using Lark
Erez Shinan
@erezsh
@decorator-factory That's cool. And scary.. Tbh parsing lisp is so easy, I'm not sure it's such a great example. But the project looks really nice!
P.S. you should link to the repo in your website
decorator-factory
@decorator-factory

Thanks :)

Tbh parsing lisp is so easy, I'm not sure it's such a great example

Yes, it's kind of trivial to rewrite a lisp parser with a simple loop using re.finditer.
The project includes another parser for types (like (λ ...&[name]|&[(name str)]|inline|block . block)), if you've seen that part of the tutorial. It's very simple as well, but it showcases using separators, 'maybe' ([ ]) and a different 'maybe' (?), so it might explain some things.

The repo link missing is an oversight, I kind didn't think about it https://github.com/decorator-factory/python-fnl/

Stjepan Jakovac
@sJakovac
@decorator-factory danke schon
decorator-factory
@decorator-factory
...continuing the discussion on pattern matching, there's another evil way:
try:
    match(arg)
except case("Quoted(Name(name))") as m:
    print(1, m.name)
except case("Quoted(Sexpr(Name(name), String(value)))") as m:
    print(2, m.name, m.value)
except case("Quoted(_)") as m:
    print(3, "aaaAA!")
except case("other") as m:
    print(4, m.other)
MegaIng
@MegaIng

Also, in the meantime I discorverd that this is not impossible:

with match(arg):
    if Quoted(Name(name)):
        print(name)
    elif Quoted(Sexpr(Name(name), String(value))):
        print(2, name, value)
    elif Quoted(_):
        print(3, "aaaAA!")
    elif other:
        print(4, other)

That is the highest level of blackmagic I found till now. But this is a hell of a lot of work.

decorator-factory
@decorator-factory
"There's one obvious way to do it", they said!
MegaIng
@MegaIng
Well, the obvious way is PEP-634
Erez Shinan
@erezsh
Guys, maybe take this to a group called "1000 ways to abuse Python" or something. This isn't exactly Lark related :)
decorator-factory
@decorator-factory
Sorry, I should've stopped that eariler.
ThatXliner
@ThatXliner
1000 ways to abuse python?
At least I wont feel bad making this yesterday:
print("Say hello to cAsE!\n\tThe world's first case-messing shell. Written in Python 🐍!\nHOW IT WORKS:\n"+'='*12+'\n1. You enter something\n2. iT TrAnSfOrMs iT To sOmEtHiNg cRaZy\n\nEnjoy! 😊 - ThatXliner')
while True:print(''.join([(lambda x,y:y.lower()if x%2==0 else y.upper())(A,B)for(A,B)in enumerate(input('(cAsE)> '))]))
Erez Shinan
@erezsh
You can call it BaSkEtCaSe
ThatXliner
@ThatXliner
Yeah I never really thought of the nAmE
That's a good name!
Hmm
Can lark generate A regex?
Wait
ThatXliner
@ThatXliner
Since it's a grammar, it ought to be a recursive regex
MegaIng
@MegaIng
Yes, but it is terrible complex and doesn't work.
I already tried, but the regex engine regex (which supports recursion) can't handle anything complex.
ThatXliner
@ThatXliner
So how does Lark work?
(I've always thought it compiles teh grammar to a single regex)
Have someone tried transpiling Lark to Swift?
Or use Nuitka and Transpile it to C++?
Erez Shinan
@erezsh
No, regex by definition doesn't support recursion
Lark implements a parsing algorithm, and uses regexes only for tokenizing
ThatXliner
@ThatXliner
oh
cool
ThatXliner
@ThatXliner
What is CYK
I don't know exactly either, but it is not a parser option you should use.
Erez Shinan
@erezsh
It's a predecessor of Earley, a little similar, but slower. It might be a little better for very ambiguous grammars, but our Earley implementation got a lot of upgrades since I last tested it, so it might not even be that
ThatXliner
@ThatXliner
Ok