Skip to content

isgasho/parsing-and-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parsing & Go

This repository provides examples I referred to in "Parsing & Go" talk

Parsing phpdoc type expressions using several approaches:

These example parsers understand these types (and their combinations):

Type Example
primitive type int, float, null, ...
type name Foo, Foo\Bar
nullable type ?T
optional key type T?
array type T[]
union type X|Y
intersection type X&Y

Package phpdoc defines the common AST constructed by every parser.

Package phpdoctest contains test cases that are used to test every parser.

Every parser package is a main that can parse a command-line argument:

go run ./participle 'int|Foo\Bar'

go run ./yacc 'int|Foo\Bar'

go run ./yacc_ragel 'int|Foo\Bar'

go run ./handwritten 'int|Foo\Bar'

Some useful make commands:

# build all parsers (requires goyacc and ragel installed)
make all

# run all tests
make test

# run all benchmarks
make bench

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 88.6%
  • Yacc 6.7%
  • Ragel 3.2%
  • Makefile 1.5%