simplified Python parsing question

Discussion in 'Python' started by Eric S. Johansson, Jul 30, 2012.

  1. as some folks may remember, I have been working on making Python and its tool
    base more accessible to disabled programmers. I've finally come up with a really
    simple technique which should solve 80% of the problem. What I need to figure
    out is how to find a spot in the code where a symbol exists and potentially,
    it's rough type (class name, instance, etc.). This is really a much bigger
    question that I want to get into right now but I'm looking just to build a demo
    to back up a storyboard plus video.

    When you are sitting on or in a name, you look to the left or look to the right
    what would you see that would tell you that you have gone past the end of that
    name. For example

    a = b + c

    if you are sitting on a, the boundaries are beginning of line and =, if you are
    sitting on b, the boundaries are = and +, if you are sitting on c, the
    boundaries are + and end of line. a call the region between those boundaries
    the symbol region.

    if this example is clear to you, what you suggest for a method of finding a
    whole statement, or a whole symbol region? note, doesn't have to be perfect or
    complete solution, just good enough to let me do a moderately complex demo and
    seek funding accessibility world to build a complete environment.

    I appreciate the help because I believe that once this is working, it'll make a
    significant difference in the ability for disabled programmers to write code
    again as well as be able to integrate within existing development team and their
    naming conventions.

    Looking forward to responses.

    --- eric

    first draft write up of technique
    https://docs.google.com/document/d/1In11apApKozw_UOPAhVz0ePqns72_6652Dra34xWp4E/edit
     
    Eric S. Johansson, Jul 30, 2012
    #1
    1. Advertising

  2. On Sun, 29 Jul 2012 19:21:49 -0400, Eric S. Johansson wrote:

    > When you are sitting on or in a name, you look to the left or look to
    > the right what would you see that would tell you that you have gone past
    > the end of that name. For example


    Have you read the docs? It gives full details of the Python syntax.

    http://docs.python.org/reference/index.html

    For example:

    http://docs.python.org/reference/simple_stmts.html#assignment-statements

    See also:

    http://docs.python.org/library/language.html
    http://effbot.org/zone/simple-top-down-parsing.htm
    http://nedbatchelder.com/text/python-parsers.html


    Here's a Python parser using the pyparsing library. It's a bit old
    (written for Python 2.4) but it shouldn't be hard to update it to new
    syntax:

    http://pyparsing.wikispaces.com/file/view/pythonGrammarParser.py



    --
    Steven
     
    Steven D'Aprano, Jul 30, 2012
    #2
    1. Advertising

  3. On 7/29/2012 11:33 PM, Steven D'Aprano wrote:
    > On Sun, 29 Jul 2012 19:21:49 -0400, Eric S. Johansson wrote:
    >
    >> When you are sitting on or in a name, you look to the left or look to
    >> the right what would you see that would tell you that you have gone past
    >> the end of that name. For example

    > Have you read the docs? It gives full details of the Python syntax.


    Yes I have. I was hoping for a different perspective because what I'm trying to
    do is middle out parsing. Top-down when the scanner focus moves from left to
    right and bottom up when the scanner focus moves from right to left.

    sounds kind of odd when I describe it that way but both the cursor is on the
    middle of a name string and I need to look to either end of that name string
    before can do a conversion to a symbol string, I have to look at both ends in
    different ways. If you've read the documentation I've provided, would it be a
    better example to use for describing some of the issues. Here's a very rough
    draft of a storyboard

    https://docs.google.com/presentation/d/1fuKyo9AE6i9ZdX2lucwK0v_W5Kx9M3Mezavm40wzCo8/edit

    the first 13-14 slides are the working content for the storyboard. the rest is
    mostly "memory" of things I was thinking about so if it doesn't make sense or
    seems wrong, don't give me grief. :)

    > Here's a Python parser using the pyparsing library. It's a bit old
    > (written for Python 2.4) but it shouldn't be hard to update it to new
    > syntax:
    >
    > http://pyparsing.wikispaces.com/file/view/pythonGrammarParser.py
    >


    thanks for the reference. I'll take a look at it as well.
     
    Eric S. Johansson, Jul 30, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey

    simplified chinese encoding

    Grey, Apr 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    517
  2. Dieter Maurer

    Re: simplified Python parsing question

    Dieter Maurer, Jul 30, 2012, in forum: Python
    Replies:
    0
    Views:
    132
    Dieter Maurer
    Jul 30, 2012
  3. Eric S. Johansson

    Re: simplified Python parsing question

    Eric S. Johansson, Jul 30, 2012, in forum: Python
    Replies:
    0
    Views:
    160
    Eric S. Johansson
    Jul 30, 2012
  4. Laszlo Nagy

    Re: simplified Python parsing question

    Laszlo Nagy, Jul 30, 2012, in forum: Python
    Replies:
    0
    Views:
    200
    Laszlo Nagy
    Jul 30, 2012
  5. Eric S. Johansson

    Re: simplified Python parsing question

    Eric S. Johansson, Jul 30, 2012, in forum: Python
    Replies:
    6
    Views:
    223
    BartC
    Aug 3, 2012
Loading...

Share This Page