php

package module
v0.0.0-...-37d2667 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2014 License: BSD-3-Clause Imports: 5 Imported by: 0

README

php

Parser for PHP written in Go

See this post for an introduction.

Build Status GoDoc

Test console:

console

Project Status

This project is under heavy development, though some pieces are more or less stable. Listed here are components that in progress or are ideas for future development

  • Lexer and Parser: these pieces are quite useable and haven't seen more than minor changes for a while. They do have notable gaps, though (e.g. namespaces).
  • Code search and symbol lookup: basic idea implemented, many many details missing
  • Code formatting: basic idea implemented, formatting needs to narrow down to PSR-2
  • Transpilation to Go: not begun.
  • Scoping: not begun.
  • Type inferencing: not begun.
  • Dead code analysis: not begun.

Project Components

  • php: the core parser
  • php/ast: (Abstract syntax tree) describes the nodes in PHP as parsed by the parser
  • php/ast/printer: prints an ast back to source code
  • php/cmd: a tool used to debug the parser
  • php/lexer: reads a stream of tokens from source code
  • php/passes: tools and packages related to modifying or analyzing PHP code (heavily a work in progress)
  • php/query: tools and packages related to analyzing and finding things in PHP code (heavily a work in progress)
  • php/testfiles: simple examples of PHP that must parse with no errors for tests to pass
  • php/token: describes the tokens read by the lexer

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	Debug       bool // Debug causes the parser to print all errors to stdout and relay any panic upon internal panic recovery.
	PrintTokens bool // PrintTokens causes the parser to print all tokens received from the lexer to stdout.
	MaxErrors   int  // Indicates the number of errors to allow before triggering a panic. The default is 10.
	// contains filtered or unexported fields
}

Parser handles scanning through and parsing a PHP source string into an AST. It is configurable to have various types of debugging features.

func NewParser

func NewParser(input string) *Parser

NewParser readies a parser object for the given input string.

func (*Parser) Parse

func (p *Parser) Parse() (nodes []ast.Node, errors []error)

Parse consumes the input string to produce an AST that represents it.

Directories

Path Synopsis
ast
cmd
fmt command
parserdebug command
Lexer transforms an input string into a stream of PHP tokens.
Lexer transforms an input string into a stream of PHP tokens.
passes
Package query implements CSS/jQuery-esque selectors over a PHP AST
Package query implements CSS/jQuery-esque selectors over a PHP AST
cmd/query command
Command query implements a simple CLI for querying a PHP AST.
Command query implements a simple CLI for querying a PHP AST.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL