Skip to content

Commit

Permalink
Merge pull request #136 from ourPLCC/fix-scan
Browse files Browse the repository at this point in the history
fix: scan reads files passed on command-line
  • Loading branch information
StoneyJackson authored May 25, 2024
2 parents c6b75f0 + a91195a commit 268b8d4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plcc/bin/scan
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init

assert_file_exists Java/Scan.class
java Scan
java Scan "$@"
25 changes: 25 additions & 0 deletions tests/end-to-end/scan/reads-files-given-on-command-line.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bats

load '../relocate_to_temp.bash'

@test "scan reads files passed on command-line" {
relocate_to_temp

cat << EOF > grammar
skip WHITESPACE '\s'
token FOO 'foo'
token BAR 'bar'
token ID '[A-Za-z]\w*'
EOF

echo "foo bar \n foobar" > in.file

TOKENS="$(
plccmk -c grammar &&
scan in.file
)"

[[ "$TOKENS" =~ "FOO 'foo'" ]]
[[ "$TOKENS" =~ "BAR 'bar'" ]]
[[ "$TOKENS" =~ "ID 'foobar'" ]]
}

0 comments on commit 268b8d4

Please sign in to comment.