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

Adjust RepHint Parsing #214

Merged
merged 5 commits into from
Jan 24, 2024
Merged

Adjust RepHint Parsing #214

merged 5 commits into from
Jan 24, 2024

Conversation

btwj
Copy link
Contributor

@btwj btwj commented Jan 17, 2024

No description provided.

aeneas/src/vst/Parser.v3 Outdated Show resolved Hide resolved
Copy link
Owner

@titzer titzer left a comment

Choose a reason for hiding this comment

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

Mostly looks good now!

def parsePacking(p: ParserState) -> VstPacking {
if (p.curByte == '0') {
p.eat1();
p.req1('b');
Copy link
Owner

Choose a reason for hiding this comment

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

We'll want to allow uppercase 'B' to be consistent with binary literals.

var chars = Vector<u8>.new();
while (q < p.input.length) {
var c = p.input[q];
if (c == '0' || c == '1' || Char.isIdentStart(c)) chars.put(c);
Copy link
Owner

Choose a reason for hiding this comment

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

Should we allow '?' here too?

} else if (Char.isIdentStart(p.curByte)) {
var packingName = parseIdentVoid(p);
var fields = parseList(0, p, '(', COMMA, ')', parseIdentVoid);
return VstPacking.Params(packingName.name, fields.map(asToken));
Copy link
Owner

Choose a reason for hiding this comment

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

You can use VstIdent<void>.name as a getter method here.

var result: VstRepHint;
if (Strings.equal(name, "boxed")) result = VstRepHint.Boxed;
else if (Strings.equal(name, "unboxed")) result = VstRepHint.Unboxed;
else if (Strings.equal(name, "packing")) {
Copy link
Owner

Choose a reason for hiding this comment

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

Packing is a keyword now; let's introduced KC_PACKING to allow it (but not other keywords) here.


type VstPacking {
case Bits(rep: string);
case Params(packingName: Token, fields: VstList<Token>);
Copy link
Owner

Choose a reason for hiding this comment

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

What about making the fields a VstList<Expr>? That way we can accommodate VarExpr and Literal.

@btwj btwj requested a review from titzer January 23, 2024 21:22
@btwj btwj marked this pull request as ready for review January 23, 2024 21:23
Copy link
Owner

@titzer titzer left a comment

Choose a reason for hiding this comment

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

lgtm

@titzer
Copy link
Owner

titzer commented Jan 24, 2024

Can you bump the version number and I'll merge this?

@titzer titzer merged commit d5e140c into titzer:master Jan 24, 2024
7 checks passed
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.

2 participants