[BUG] Mis-alignment when parsing accents · Issue #375 · tree-sitter/tree-sitter-c-sharp · GitHub
Skip to content

[BUG] Mis-alignment when parsing accents #375

Description

@nicolas-goyon

Hi, I am unsure of what to put here so i'll try to put as much information as i can.

Context

I'm currently using the pip library.

The problem

Using accents create an offest in the AST.

I can't stop using them because I have user feedback (not in this code, but in general in my software)

Using accents

The Csharp script

Details
using System.Text.RegularExpressions;

namespace HUBLoader.Types;


public class TypeArret
{
    private readonly string bits;

    public TypeArret(string rawBits)
    {
        if (rawBits.Length != 20)
            throw new ArgumentException($"TypeArret doit contenir exactement 20 caractères (reçu {rawBits.Length})");

        if (!Regex.IsMatch(rawBits, "^[ON]{20}$", RegexOptions.IgnoreCase))
            throw new ArgumentException("TypeArret ne doit contenir que des caractères 'O' ou 'N'.");

        bits = rawBits.ToUpperInvariant();
    }

    public bool EstActif(TypeArretFlag flag)
    {
        return bits[(int)flag] == 'O';
    }

    public override string ToString()
    {
        return bits;
    }
}

AST to JSON

Too long for github

Without accents

Csharp script

Details
using System.Text.RegularExpressions;

namespace HUBLoader.Types;


public class TypeArret
{
    private readonly string bits;

    public TypeArret(string rawBits)
    {
        if (rawBits.Length != 20)
            throw new ArgumentException($"TypeArret doit contenir exactement 20 caracteres (recu {rawBits.Length})");

        if (!Regex.IsMatch(rawBits, "^[ON]{20}$", RegexOptions.IgnoreCase))
            throw new ArgumentException("TypeArret ne doit contenir que des caracteres 'O' ou 'N'.");

        bits = rawBits.ToUpperInvariant();
    }

    public bool EstActif(TypeArretFlag flag)
    {
        return bits[(int)flag] == 'O';
    }

    public override string ToString()
    {
        return bits;
    }
}

AST to JSON

Too long for github

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions