Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pass more information in user defined parse error#1106

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
windelbouwman merged 3 commits intoRustPython:masterfrompalaviv:syntex-error
Jul 6, 2019

Conversation

@palaviv
Copy link
Contributor

Before the message was:

Traceback (mostrecentcalllast):SyntaxError:'Got unsupported token(s) at line 0'

And now it is:

Traceback (mostrecentcalllast):SyntaxError:'Got unexpected token\t at line 4 column 25'

// Print line number:
write!(f," at line {:?}",self.location.row())
match&self.error{
CompileErrorType::Parse(..) =>Ok(()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmm. This exception for the parse error is not ideal, but we can improve on this later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please implement the todo at this line:

location:Default::default(),// TODO: extract location from parse error!

Then we have proper locations on all compiler errors (where possible).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done

UnrecognizedToken(TokSpan,Vec<String>),
/// Maps to `User` type from `lalrpop-util`
Other,
Other(LexicalError),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It might be good to rename this error variant intoLexical(LexicalError).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done

InnerError::ExtraToken{ token} =>ParseError::ExtraToken(token),
// Inner field is a unit-like enum `LexicalError::StringError` with no useful info
InnerError::User{ ..} =>ParseError::Other,
InnerError::User{ error} =>ParseError::Other(error),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is very good to propagate the lexer errors!

}
LexicalErrorType::OtherError(ref msg) =>write!(f,"{}", msg),
}?;
write!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would prefer to add the line and column info later on, so in theDisplay method of theCompilerError struct.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done

@windelbouwman
Copy link
Contributor

This change looks very good now. The only thing left is to take a look at the wasm build.

@palaviv
Copy link
ContributorAuthor

I am trying to fix the wasm but the error currently look like:

SyntaxError:ErrorparsingPythoncode:Gotunexpectedtoken:DoubleStaratLocation {row:1,column:8 }atline0

Not sure why thefmt::Display I defined is not working.

);
}
}
let _ =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Well, adding thelocation attribute clearly was beneficial!

@windelbouwmanwindelbouwman merged commit70c2054 intoRustPython:masterJul 6, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@windelbouwmanwindelbouwmanwindelbouwman approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@palaviv@windelbouwman

[8]ページ先頭

©2009-2025 Movatter.jp