Gelatin icon indicating copy to clipboard operation
Gelatin copied to clipboard

Quick start example does not run

Open roedoejet opened this issue 6 years ago • 0 comments

Hi there,

I appear to be getting some strange indenting errors. When I copy the quickstart .gel file and text and run the provided command, I get the error Exception: indent must be a multiple of 4, is 14 in line 24: u' user('

I am using Python 3.7.3, Visual Studio Code with spaces set to 4 and UTF-8 encoding.

Here is the copied quickstart syntax file:

# Define commonly used data types. This is optional, but
# makes your life a litte easier by allowing to reuse regular
# expressions in the grammar.
define nl /[\r\n]/
define ws /\s+/
define fieldname /[\w ]+/
define value /[^\r\n,]+/
define field_end /[\r\n,] */

grammar user:
    match 'Name:' ws value field_end:
        out.add_attribute('.', 'firstname', '$2')
    match 'Lastname:' ws value field_end:
        out.add_attribute('.', 'lastname',  '$2')
    match fieldname ':' ws value field_end:
        out.add('$0', '$3')
    match nl:
        do.return()

# The grammar named "input" is the entry point for the converter.
grammar input:
    match 'User' nl '----' nl:
        out.open('user')
        user()

and the copied text:

User
----
Name: John, Lastname: Doe
Office: 1st Ave
Birth date: 1978-01-01

User
----
Name: Jane, Lastname: Foo
Office: 2nd Ave
Birth date: 1970-01-01

The indentation provided for the syntax file in the docs (https://gelatin.readthedocs.io/en/latest/quick.html) is different from the Readme, but also does not work.

roedoejet avatar Aug 12 '19 19:08 roedoejet