Skip to content

Commit 3d47b48

Browse files
author
Kristian Larsson
committed
Parse payloads from Text slices
Literal and token parsers still converted through String or built Text one character at a time. Capture chunks from the Text input directly for identifiers, numbers, string fragments, format specs, quote runs, and escape digits. This keeps source spans stable and makes the affected numeric diagnostics use more precise decimal and hexadecimal digit labels, while reducing intermediate allocation before AST construction. Update the kinds and types bench readers to keep benchmark sources in Text too.
1 parent b09cb60 commit 3d47b48

8 files changed

Lines changed: 373 additions & 165 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Building file test/syntaxerrors/err10.act using temporary scratch directory
22
[error Parse error]: unexpected newline
3-
expecting ':', call arguments, slice/index expression, digit, if clause, or operator
3+
expecting ':', call arguments, slice/index expression, decimal digit, if clause, or operator
44

55
+--> test/syntaxerrors/err10.act@3:13-3:14
66
|
77
3 | if x > 0
88
: ^
99
: `- unexpected newline
10-
: expecting ':', call arguments, slice/index expression, digit, if clause, or operator
10+
: expecting ':', call arguments, slice/index expression, decimal digit, if clause, or operator
1111
:
1212
-----+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Building file test/syntaxerrors/err15.act using temporary scratch directory
22
[error Parse error]: unexpected '}'
3-
expecting call arguments, slice/index expression, closing ']', comma, digit, if clause, or operator
3+
expecting call arguments, slice/index expression, closing ']', comma, decimal digit, if clause, or operator
44

55
+--> test/syntaxerrors/err15.act@4:17-4:18
66
|
77
4 | return arr[0}
88
: ^
99
: `- unexpected '}'
10-
: expecting call arguments, slice/index expression, closing ']', comma, digit, if clause, or operator
10+
: expecting call arguments, slice/index expression, closing ']', comma, decimal digit, if clause, or operator
1111
:
1212
-----+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Building file test/syntaxerrors/err27.act using temporary scratch directory
22
[error Parse error]: unexpected "ab"
3-
expecting ';', call arguments, slice/index expression, comma, digit, end of line, if clause, or operator
3+
expecting ';', call arguments, slice/index expression, comma, decimal digit, end of line, if clause, or operator
44

55
+--> test/syntaxerrors/err27.act@3:15-3:16
66
|
77
3 | return 123abc
88
: ^
99
: `- unexpected "ab"
10-
: expecting ';', call arguments, slice/index expression, comma, digit, end of line, if clause, or operator
10+
: expecting ';', call arguments, slice/index expression, comma, decimal digit, end of line, if clause, or operator
1111
:
1212
-----+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Building file test/syntaxerrors/err37.act using temporary scratch directory
22
[error Parse error]: unexpected "b1"
3-
expecting ';', call arguments, slice/index expression, comma, digit, end of line, if clause, or operator
3+
expecting ';', call arguments, slice/index expression, comma, decimal digit, end of line, if clause, or operator
44

55
+--> test/syntaxerrors/err37.act@3:13-3:14
66
|
77
3 | return 0b102
88
: ^
99
: `- unexpected "b1"
10-
: expecting ';', call arguments, slice/index expression, comma, digit, end of line, if clause, or operator
10+
: expecting ';', call arguments, slice/index expression, comma, decimal digit, end of line, if clause, or operator
1111
:
1212
-----+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Building file test/syntaxerrors/err38.act using temporary scratch directory
22
[error Parse error]: unexpected 'G'
3-
expecting hexadecimal integer
3+
expecting hexadecimal digit
44

55
+--> test/syntaxerrors/err38.act@3:14-3:15
66
|
77
3 | return 0xGHI
88
: ^
99
: `- unexpected 'G'
10-
: expecting hexadecimal integer
10+
: expecting hexadecimal digit
1111
:
1212
-----+

compiler/lib/bench/KindsBench.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import qualified Acton.Syntax as Syntax
77
import Control.DeepSeq (rnf)
88
import qualified Control.Exception as E
99
import qualified Data.HashMap.Strict as HashMap
10+
import qualified Data.Text.IO as TIO
1011
import Data.Time.Clock (diffUTCTime, getCurrentTime)
1112
import GHC.Stats
1213
import System.Environment (getArgs)
@@ -45,7 +46,7 @@ main = do
4546
case args of
4647
[typesPath, sourcePath] -> do
4748
statsEnabled <- getRTSStatsEnabled
48-
src <- readFile sourcePath
49+
src <- TIO.readFile sourcePath
4950
env0 <- Env.initEnv typesPath False
5051
let modName = Syntax.modName [takeBaseName sourcePath]
5152

compiler/lib/bench/TypesBench.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import qualified Acton.Types as Types
88
import Control.DeepSeq (rnf)
99
import qualified Control.Exception as E
1010
import qualified Data.HashMap.Strict as HashMap
11+
import qualified Data.Text.IO as TIO
1112
import Data.Time.Clock (diffUTCTime, getCurrentTime)
1213
import GHC.Stats
1314
import System.Environment (getArgs)
@@ -46,7 +47,7 @@ main = do
4647
case args of
4748
[typesPath, sourcePath] -> do
4849
statsEnabled <- getRTSStatsEnabled
49-
src <- readFile sourcePath
50+
src <- TIO.readFile sourcePath
5051
env0 <- Env.initEnv typesPath False
5152
let modName = Syntax.modName [takeBaseName sourcePath]
5253

0 commit comments

Comments
 (0)