Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Parsing Error: negative number in parentheses like "(-1)" #6

Closed
lateau opened this Issue · 7 comments

2 participants

@lateau

see log:

$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
$ ruby -e "(-1)"
$ ruby -e "puts (-1).class"
Fixnum

$ ./cardinal -e "(-1)"
unterminated statement at line 1, near ")"

current instr.: 'cardinal;PGE;Util;die' pc 80 (runtime/parrot/library/PGE/Util.pir:67)
called from Sub 'cardinal;cardinal;Grammar;stmts' pc 15177 (src/classes/Array.pir:777)
called from Sub 'cardinal;cardinal;Grammar;comp_stmt' pc 13769 (src/classes/Array.pir:249)
called from Sub 'cardinal;cardinal;Grammar;pcomp_stmt' pc 38698 (src/builtins/globals.pir:9619)
called from Sub 'cardinal;cardinal;Grammar;basic_primary' pc 37165 (src/classes/FileStat.pir:9056)
called from Sub 'cardinal;cardinal;Grammar;indexed_assignment' pc 22668 (src/classes/Array.pir:3607)
called from Sub 'cardinal;cardinal;Grammar;basic_stmt' pc 17293 (src/classes/Array.pir:1577)
called from Sub 'cardinal;cardinal;Grammar;stmt' pc 19096 (src/classes/Array.pir:2227)
called from Sub 'cardinal;cardinal;Grammar;stmts' pc 14288 (src/classes/Array.pir:448)
called from Sub 'cardinal;cardinal;Grammar;comp_stmt' pc 13769 (src/classes/Array.pir:249)
called from Sub 'cardinal;cardinal;Grammar;TOP' pc 13424 (src/classes/Array.pir:115)
called from Sub 'cardinal;PCT;HLLCompiler;parse' pc 826 (compilers/pct/src/PCT/HLLCompiler.pir:463)
called from Sub 'cardinal;PCT;HLLCompiler;compile' pc 464 (compilers/pct/src/PCT/HLLCompiler.pir:331)
called from Sub 'cardinal;PCT;HLLCompiler;eval' pc 1081 (compilers/pct/src/PCT/HLLCompiler.pir:582)
called from Sub 'cardinal;PCT;HLLCompiler;command_line' pc 1759 (compilers/pct/src/PCT/HLLCompiler.pir:884)
called from Sub 'cardinal;cardinal;Compiler;main' pc 78838 (src/gen_grammar.pir:5369)

@leto
Owner

We need a failing test for this, it is a good beginner bug.

@lateau

OK I got it.

@lateau

I knew that (negative number) occurs parsing error but didn't know that's only can be when it stay alone.
(neg num) does not occur the error in if stmt.

I have added three tests for them and now it returns 1 with error messages.
I'll send pull request. Tested on parrot3.8.0.

Test Summary Report

t/01-stmts.t (Tests: 0 Failed: 0)
Non-zero exit status: 1
Parse errors: Unknown TAP token: "unterminated statement at line 71, near ")\nputs \"ok""
Unknown TAP token: ""
Unknown TAP token: "current instr.: 'cardinal;PGE;Util;die' pc 135 (runtime/parrot/library/PGE/Util.pir:86)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;stmts' pc 15406 (src/classes/Array.pir:777)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;comp_stmt' pc 13998 (src/classes/Array.pir:249)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;pcomp_stmt' pc 38927 (src/classes/Dir.pir:9619)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;basic_primary' pc 37394 (src/classes/FileStat.pir:9056)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;indexed_assignment' pc 22897 (src/classes/Array.pir:3607)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;basic_stmt' pc 17522 (src/classes/Array.pir:1577)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;stmt' pc 19325 (src/classes/Array.pir:2227)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;stmts' pc 14517 (src/classes/Array.pir:448)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;comp_stmt' pc 13998 (src/classes/Array.pir:249)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Grammar;TOP' pc 13653 (src/classes/Array.pir:115)"
Unknown TAP token: "called from Sub 'cardinal;PCT;HLLCompiler;parse' pc 826 (compilers/pct/src/PCT/HLLCompiler.pir:463)"
Unknown TAP token: "called from Sub 'cardinal;PCT;HLLCompiler;compile' pc 464 (compilers/pct/src/PCT/HLLCompiler.pir:331)"
Unknown TAP token: "called from Sub 'cardinal;PCT;HLLCompiler;eval' pc 1081 (compilers/pct/src/PCT/HLLCompiler.pir:582)"
Unknown TAP token: "called from Sub 'cardinal;PCT;HLLCompiler;evalfiles' pc 1501 (compilers/pct/src/PCT/HLLCompiler.pir:764)"
Unknown TAP token: "called from Sub 'cardinal;PCT;HLLCompiler;command_line' pc 1719 (compilers/pct/src/PCT/HLLCompiler.pir:875)"
Unknown TAP token: "called from Sub 'cardinal;cardinal;Compiler;main' pc 79404 (src/gen_grammar.pir:105) (src/parser/actions.pm:1)"
No plan found in TAP output
Files=108, Tests=628, 319.090 wallclock secs
Result: FAIL
test fails
current instr.: 'setup' pc 902 (runtime/parrot/library/distutils.pir:395)

thrown from:
current instr.: '_test' pc 6403 (runtime/parrot/library/distutils.pir:2181)
called from Sub 'run_step' pc 956 (runtime/parrot/library/distutils.pir:423)
called from Sub 'setup' pc 902 (runtime/parrot/library/distutils.pir:395)

@leto
Owner

Tests have been added to t/01-stmts.t, now we need somebody to make them pass.

@lateau

I'm going on fixing this problem on src/parser/grammar.pg
There're more problems same with this, every literals.

If all tests are passed, I'll request pull to parrot/cardinal.

@leto
Owner

Thanks, @lateau ! Feel free to add as many more tests as you need for other kinds of literals.

@lateau lateau referenced this issue from a commit
@lateau lateau Patch for issue #6
this change allows:
  * almost statments enclosed by '()'
  * some literals enclosed by '()': show t/01-stmts.t for the details
ab17c75
@lateau lateau referenced this issue from a commit
@lateau lateau Patch for issue #6
this change allows:
  * almost statments enclosed by '()'
  * some literals enclosed by '()': show t/01-stmts.t for the details
t/01-stmts.t will be failed because I added more test cases cannot be parsed on current cardinal.
8152425
@leto
Owner

Done

@leto leto closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.