Handle integer parsing exceptions in the lexer

オープン 初心者向け
#5 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
compilers

調査の方向性

compiler/main.cppで、issueで特定された整数の解析経路から調べ、lexerがトークンの位置を記録し、構文エラーを報告する方法を追ってください。不正な整数トークンと大きすぎる整数トークンがどのように処理されるかを確認し、それらに対してトークンの行と列を示す明確なエラーが出力され、std::stoiの例外が捕捉されずに発生しないことを検証してください。

索引モデルが issue の本文から書いたものです。

説明

bug compiler copilot good first issue help wanted

Summary

The compiler tokenizes integers using std::stoi without validating the token or catching invalid conversion exceptions.

Problem

A numeric token like +, -, or an oversized integer can produce an exception instead of a clean syntax error. That creates hard-to-diagnose crashes during assembly.

Expected behavior

  • Reject malformed integer literals with a clear error message.
  • Report the line and column of the invalid token.
  • Avoid uncaught exceptions from std::stoi.

Relevant code

  • compiler/main.cpp in the integer parsing path.

Suggested fix

Before calling std::stoi, validate the token string and catch std::invalid_argument/std::out_of_range to convert them into syntax errors with source positions.

主要言語
C++
スター
0
フォーク
0
平均マージ
1分
マージ済み PR(30日)
4

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DavidSkillman/LittleManCompiler のほかの issue

DavidSkillman/LittleManCompiler の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。