Open flip111 opened 9 years ago
Try:
test : HELLO WORLD ;
On Wed, Oct 22, 2014 at 2:41 PM, flip111 notifications@github.com wrote:
I have my test file like this
//option namespace:someNamespace //option class:someClass //option fileName:out.php //option extends:someExtend //option parserValue:someParser
//Lexical Grammar %lex
HELLO hello WORLD world
//Create tokens from lexical analysis %% HELLO { return 'hi'; }
WORLD { return 'planet'; }
/lex
%%
test : HELLO WORLD
When i run jison it returns:
Executing: jison test.jison Failed: 8
Is this a mistake of the grammar or another thing that is going wrong entirely??
— Reply to this email directly or view it on GitHub https://github.com/robertleeplummerjr/jison/issues/4.
Robert Plummer
this helped a little bit i guess ..
Executing: jison test.jison
Opening newly created jison js file: test.js
Something went bad
what does that mean?
just execute jison test.jison and ensure it is working before trying it with ports.
On Wed, Oct 22, 2014 at 2:52 PM, flip111 notifications@github.com wrote:
this helped a little bit i guess ..
Executing: jison test.jison
Opening newly created jison js file: test.js Something went bad
what does that mean?
— Reply to this email directly or view it on GitHub https://github.com/robertleeplummerjr/jison/issues/4#issuecomment-60135542 .
Robert Plummer
That test file didn't work, i corrected it to this
test.jison
//option namespace:someNamespace
//option class:someClass
//option fileName:out.php
//option extends:someExtend
//option parserValue:someParser
//Lexical Grammar
%lex
//Create tokens from lexical analysis
%%
hello { return 'HELLO'; }
world { return 'WORLD'; }
\s+ {/* skip whitespace */}
/lex
%%
test
: HELLO WORLD ;
input.txt
hello world
Executed commands:
jison test.jison
node test.js input.txt
This gave no error so i assume everything went succesful. However i don't know yet how i can access the generated AST.
Using those files like that and trying it with the php port:
D:\dev\console\jisonTest>node %APPDATA%\npm\node_modules\jison\ports\php\php.js test.jison
Executing: jison test.jison
Opening newly created jison js file: test.js
Something went bad
What happens when you execute jison test.jison?
On Fri, Oct 24, 2014 at 2:55 PM, flip111 notifications@github.com wrote:
That test file didn't work, i corrected it to this
test.jison
//option namespace:someNamespace //option class:someClass //option fileName:out.php //option extends:someExtend //option parserValue:someParser
//Lexical Grammar %lex
//Create tokens from lexical analysis %% hello { return 'HELLO'; } world { return 'WORLD'; } \s+ {/* skip whitespace */}
/lex
%%
test : HELLO WORLD ;
input.txt
hello world
Executed commands:
jison test.jison node test.js input.txt
This gave no error so i assume everything went succesful. However i don't know yet how i can access the generated AST.
Using those files like that and trying it with the php port:
D:\dev\console\jisonTest>node %APPDATA%\npm\node_modules\jison\ports\php\php.js test.jison Executing: jison test.jison
Opening newly created jison js file: test.js Something went bad
— Reply to this email directly or view it on GitHub https://github.com/robertleeplummerjr/jison/issues/4#issuecomment-60433080 .
Robert Plummer
nothing visible in console (one empty line to be precise)
D:\dev\console\jisonTest>jison test.jison
D:\dev\console\jisonTest>
I looked at the calculator example and i noticed it was using some extra commands typeof console !== 'undefined' ? console.log($1) : print($1); return $1;
. So i added that into my file and now i get output hello
. Ok not hello world
.. so there is still something wrong but at least it's parsing it without errors and i get some result.
//option namespace:someNamespace
//option class:someClass
//option fileName:out.php
//option extends:someExtend
//option parserValue:someParser
//Lexical Grammar
%lex
//Create tokens from lexical analysis
%%
hello { return 'HELLO'; }
world { return 'WORLD'; }
\s+ {/* skip whitespace */}
/lex
%%
test
: HELLO WORLD {
typeof console !== 'undefined' ? console.log($1) : print($1);
return $1;
};
As for the PHP version it still doesn't work.
Hi i found the bug. This line assumes that the input file lines are terminated by \n
but in my case they are terminated by \r\n
. Then later the filename out.php
is replaced by out.php\r
and windows can not write a filename like this so the error occurs.
Nice find, we should then handle both windows and linux lines.
On Sat, Nov 1, 2014 at 1:25 PM, flip111 notifications@github.com wrote:
Hi i found the bug. This line https://github.com/robertleeplummerjr/jison/blob/master/ports/php/php.js#L91 assumes that the input file lines are terminated by \n but in my case they are terminated by \r\n. Then later https://github.com/robertleeplummerjr/jison/blob/master/ports/php/php.js#L92-L98 the filename out.php is replaced by out.php\r and windows can not write a filename like this so the error occurs.
— Reply to this email directly or view it on GitHub https://github.com/robertleeplummerjr/jison/issues/4#issuecomment-61375715 .
Robert Plummer
I have my test file like this
When i run jison it returns:
Is this a mistake of the grammar or another thing that is going wrong entirely??