Skip to content

pass current line and column to action #72

Open
@gadlopes

Description

Dear developers,
Is there a way to pass the current line and column of the file being parsed to the action of a rule?

For example:

the grammar:

parameter = (word:w -> AnAction('parameter',str(w),line,column) )

the python file:

def AnAction(name, value, line, column):
   print(value +' ' + str(line) + ' ' + str(column))

the input text:

hello this is
a test

the output:

hello 1 1
this 1 7
is 1 12
a 2 1
test 2 3

I'm trying to build a compiler and I would like to check if a variable is already defined. So to make an error message it would be nice if Parsley would provide me with the location of the variable, even when the file has the correct syntax.

Thanks in advance!!!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions