Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.58 KB

README.md

File metadata and controls

51 lines (35 loc) · 1.58 KB

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