Giter Site home page Giter Site logo

hello world grammar mistake? about bovid.js HOT 9 OPEN

flip111 avatar flip111 commented on September 14, 2024
hello world grammar mistake?

from bovid.js.

Comments (9)

robertleeplummerjr avatar robertleeplummerjr commented on September 14, 2024

Try:

test
: HELLO WORLD ;

On Wed, Oct 22, 2014 at 2:41 PM, flip111 [email protected] 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

from bovid.js.

flip111 avatar flip111 commented on September 14, 2024

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?

from bovid.js.

robertleeplummerjr avatar robertleeplummerjr commented on September 14, 2024

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 [email protected] 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

from bovid.js.

flip111 avatar flip111 commented on September 14, 2024

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

from bovid.js.

robertleeplummerjr avatar robertleeplummerjr commented on September 14, 2024

What happens when you execute jison test.jison?

On Fri, Oct 24, 2014 at 2:55 PM, flip111 [email protected] 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

from bovid.js.

flip111 avatar flip111 commented on September 14, 2024

nothing visible in console (one empty line to be precise)

D:\dev\console\jisonTest>jison test.jison

D:\dev\console\jisonTest>

from bovid.js.

flip111 avatar flip111 commented on September 14, 2024

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.

from bovid.js.

flip111 avatar flip111 commented on September 14, 2024

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.

from bovid.js.

robertleeplummerjr avatar robertleeplummerjr commented on September 14, 2024

Nice find, we should then handle both windows and linux lines.

On Sat, Nov 1, 2014 at 1:25 PM, flip111 [email protected] 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

from bovid.js.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.