Code Monkey home page Code Monkey logo

goyacc's People

Contributors

cznic avatar myitcv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goyacc's Issues

invalid syntax error on $

i am trying to consume a large grammer file (postgresql) which is in Bison format.
Bison is supposed to be the GNU implementation/extension of Yacc but I think it has some differences since I got a syntax error. I have not spent time to find out the differences between Yacc/Bison related to this. Maybe you can comment on that.

The section that cause the error is

OptSchemaEltList:
            OptSchemaEltList schema_stmt
                {
                    if (@$ < 0)         /* see comments for YYLLOC_DEFAULT */
                        @$ = @2;
                    $$ = lappend($1, $2);
                }
            | /* EMPTY */
                { $$ = NIL; }
        ;

The @$ causes: strconv.ParseInt: parsing "": invalid syntax:

Newline may get lost in semantic action

$ cat test.y
%union {
    val string
}

%token <val> INT

%%

Start:
    INT
    {
        _ = $1
        return 0
    }
$ goyacc -o /dev/stdout 2>/dev/null test.y | grep valreturn
        _ = stack[sp-0].valreturn 0
$ 

same *.y file has different output in different system.

I have a *.y file to generate a parser for sql, but I found there was different output between MacOS(10.13) and Linux(CentOS 6.3).
Ant the output parser from MacOS not working good. I had to generate the parser on linux and send the parser file to mac to continue my work.
There are lost of different between to parser.

I use the command like this:

goyacc -o sql.go sql.y
gofmt -w sql.go

How build goyacc tool in GO

hi
How build goyacc tool in GO?

i have goyacc -h package in my system.
but want install go tool yacc on go 1.8
how can do this?

$ make

go fmt
go test
PASS
ok github.com/cznic/goyacc 0.002s
go install
go tool vet -printfuncs "Log:0,Logf:1" *.go
golint .
make todo
make[1]: Entering directory '/home/guest/go/src/github.com/cznic/goyacc'
main.go:554: _ = yyerrok
main.go:706: _ = yypt // guard against "declared and not used"
main.go:791: _ = oNoLines //TODO Ignored for now
all_test.go:37:func TODO(...interface{}) string {
all_test.go:39: return fmt.Sprintf("TODO: %s:%d:\n", path.Base(fn), fl)
main.go:791: _ = oNoLines //TODO Ignored for now
make[1]: Leaving directory '/home/guest/go/src/github.com/cznic/goyacc'

yacc

Hi,

parser.y:36:41: $$ of declarations has no declared type (and 30 more errors)
what does it complain?

program: declarations 
{
}

declarations: declaration
{
  declarationNode := newDeclarationNode($$.funcDecl)
  $$.node = declarationNode

  cast(yylex).SetAstRoot($$.node)
}

Missed typecheck.

$ cat bug.y
%union{
    val  int
    vals []int
}

%token  I
%type   <vals>  L

%%

S:  L

L:
    {
        $$ = []int(nil)
    }
|   L I
    {
        $$ = append($$, $2)
    }
$ goyacc -o /dev/stdout bug.y | grep yypt-0
Parse table entries: 5 of 24, x 8 bits == 5 bytes
        yyVAL.vals = append(yyVAL.vals, yyS[yypt-0].)
$ 

Token I should have been declared as %token <val> I, but the missing type of $2 gets undetected by the y package. Goyacc then renders invalid Go code.

Stabilize token values.

Token values are assigned when ranging a map. Make the order of assigning the values stable to improve VCS diffs.

func yylex1: yyEofCode is hardcoded

... as -1, but the value generated by cznic/y should be used instead.

And one more bug in error recovery - instead of proper stem there's a hardcoded yy.

Duplicate index in yyParseTab

I have a parser that has the following basic structure:

program
    : statements
    ;
statements
    : statement
    | statement statements
    ;

And I am getting the following error: y.go:348:12: duplicate index in array literal: 5
I opened up y.go and lines 345-349 look like this:

yyParseTab = [83][]uint8{
    // 0
    {4: 46, 14: 50, 49, 25: 47, 32: 48, 45, 44, 36: 43},
    {5: 42, 5: 42, 5: 42, 5: 42, 5: 42},
    {1: 41, 5: 41, 41, 12: 41, 41},
    ...
}

If I'm not mistaken, it looks like the error corresponds to state 1. But I'm not a yacc expert, by any means. Looking at y.output for state 1 gives the following:

state 1 // NAME SEMICOLON [$end]
    
    0 $accept: program .  [$end, AND, ARROW, LCURLY, OR]

    $end    accept
    AND     accept
    ARROW   accept
    LCURLY  accept
    OR      accept

So, I think I'm reading this correctly as "we just reduced program, so check whether the next token is $end, AND, ARROW, LCURLY, or OR." I'm not sure why it would be checking that though because there is no valid token other than $end that can occur after reducing to program, which is making me think this may be an issue with goyacc. It appears to work if I manually alter the entry to just {5: 42}. Thoughts?

RFE: Token dumper in the generated Go.

I feel as though I should not have had to write this:

// Tokname returns the string name of a token type (for testing purposes).
func Tokname(i int) string {
	if i < 128 {
		return string([]byte{byte(i & 0xff)})
	}
	return cparseTokname(i - 57342)
}

That magic number is particularly annoying.

Would you please make something equivalent a public method?

example

Hi,

could you upload some examples which uses goyacc together with golex?

Thanks,
Gerald

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.