GithubHelp home page GithubHelp logo

Comments (2)

arithy avatar arithy commented on July 17, 2024

The example TinyC might be helpful to find the solution for precise counting rows and columns.
It uses the customized macro PCC_GETCHAR() with the text reader function system__read_source_file(). In this function, line break positions in bytes are recorded by calling append_line_head_() while fetching byte characters from an input text. The parsing positions in the input text can be detected using the predefined variables $0s and $0e (see README.md). The row number and the column number are computed in the function compute_line_and_column_() using line break positions and the parsing position. If not supporting multibyte characters, the code below

count_characters_(obj->source.text.p, obj->source.line.p[i - 1], pos) + 1

can be simplified with

pos - obj->source.line.p[i - 1] + 1

Unless considering multibyte characters, the input text needn't be memorized as the example does. Regarding error reporting, the example does it like this using system__handle_syntax_error().

from packcc.

arithy avatar arithy commented on July 17, 2024

@joagre , I'm wondering if my answer was what you wanted. If not so, let me know it.
I'll close this issue in a week if no reply. Feel free to reopen it when you need.

from packcc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.