Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix #77: Fix error and debug line/columns #78

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

NoelTautges
Copy link
Contributor

@NoelTautges NoelTautges commented Jan 28, 2025

This PR fixes #77 by:

  1. Changing lineCharIdx to be fully 0-indexed: Currently, it's technically 0-indexed, but it gets set to 1 immediately when parsing starts because advance() gets called to load char. On subsequent lines, it gets set to 0, but it gets reset when advancing to a newline character.
  2. Changing to a new line after advancing from a newline character, not advancing to a newline character: In the error in my issue, the parser error is called after the action call is consumed and the parser gets advanced to the newline, which increments the line counter and resets the column counter. I also removed some lineIdx-- calls that I think were put in place to decrement the line counter after advancing to a newline when consuming some identifiers.
  3. Making previous/current/next character positions variable: They were all the same before - now they're based on the previous character being a newline or not.

The part I'm most unsure of is the if statement in the copy-paste section - I deleted that because it didn't seem to do anything useful with the changes above, but I don't fully understand why it was there in the first place, so if you could review that for me, I would be grateful.

Thank you!

The debug output of the example looks like this now:

Parsing test_errors.cherri...
Parsing includes...
### INCLUDES ###

## INCLUDED ##
[]

## INCLUDES MAP ##
[]

Done.


Invalid value 0 (number) for argument 'output' (text).
output(text output)

----- test_errors.cherri:1:10
1 | output(0)
             ^
2 | alert("Test!")
-----

###################
#   DEBUG PANIC   #
###################

### PARSING ###

Previous Character:
) 1:9

Current Character:
LF 1:10

Next Character:
a 2:1

Current Line:
output(0)
## TOKENS ##

## DEFINITIONS ##
Name: test_errors
Color: -1263359489
Glyph: 61440
Inputs: []
Outputs: []
Workflows: []
No Input: { []}
macOS Only: false
Client Version: 3036.0.4.2
iOS Version: 18.0

## VARIABLES ##

## MENUS ##
map[]

## IMPORT QUESTIONS ##
map[]

### PLIST GEN ###

## UUIDS ##
map[]

### CUSTOM ACTIONS ###

### INCLUDES ###

## INCLUDED ##
[]

## INCLUDES MAP ##
[]

#############################################################

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error and debug messages point to wrong line/column
1 participant