Get master in line with develop (Merge branch 'develop')

This commit is contained in:
Peter Steenbergen 2019-02-02 10:54:18 +01:00
commit 83b309e96b
167 changed files with 2352 additions and 163 deletions

View File

@ -27,22 +27,8 @@ More information about the Mycroft A.I. software stack at https://mycroft.ai
At this moment development is in very early stages and focussed on the Raspberry Pi 3B. As soon as an initial first workable version
is created, other hardware might be added.
### Getting the code.
First, get the code on your system! The simplest method is via git.
- cd ~/
- git clone --recurse-submodules https://github.com/j1nx/MycroftOS.git
- cd MycroftOS
If this is the very first time you are going to build an image, you need to execute the following command once;
- ./scripts/br-patches.sh
### Building the code.
Then we can build the image(s) by running the following command;
- ./scripts/build.sh
(At this moment only one image get's build. Namely the one for RPi3B. Later on in time this section will get expanded with other hardware such as, the other Raspberry Pi's, perhaps Mark-1 and/or Mark-2 and further down the road for the new Rockchip RK3399Pro SoC with RK1808 NPU
... More building instructions will follow soon ...
## Documentation.
More information and instructions can be found within the "documentation" folder.
## Credits
Mycroft AI (@MycroftAI)<br>

View File

@ -7,6 +7,7 @@ menu "Additional external python modules"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-bs4/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-cachetools/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-casttube/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-colorzero/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-coverage/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-coveralls/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-deprecated/Config.in"
@ -18,6 +19,7 @@ menu "Additional external python modules"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-google-api-python-client/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-google-auth-httplib2/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-google-auth/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-gpiozero/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-gtts/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-gtts_token/Config.in"
source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-humanhash3/Config.in"

View File

@ -34,3 +34,4 @@ disable_splash=1
dtparam=i2c_arm=on
dtoverlay=i2s-mmap
dtparam=i2s=on
dtparam=spi=on

View File

@ -4,23 +4,20 @@ BR2_ARM_FPU_NEON_VFPV4=y
BR2_DL_DIR="../downloads"
BR2_CCACHE=y
BR2_CCACHE_DIR="../ccache"
# BR2_STRIP_strip is not set
BR2_OPTIMIZE_FAST=y
BR2_SHARED_STATIC_LIBS=y
BR2_GLOBAL_PATCH_DIR="../buildroot-patches"
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_14=y
BR2_TOOLCHAIN_BUILDROOT_LOCALE=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY=y
BR2_TARGET_GENERIC_HOSTNAME="MycroftOS"
BR2_TARGET_GENERIC_ISSUE="Welcome to MycroftOS"
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
BR2_INIT_SYSTEMD=y
BR2_TARGET_GENERIC_ROOT_PASSWD="mycroft"
BR2_SYSTEM_BIN_SH_BASH=y
# BR2_TARGET_GENERIC_GETTY is not set
BR2_SYSTEM_DHCP="eth0"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_US.UTF8"
BR2_GENERATE_LOCALE="en_US en_US.UTF-8"
BR2_TARGET_TZ_INFO=y
# BR2_ENABLE_LOCALE_PURGE is not set
BR2_GENERATE_LOCALE="en_US.UTF-8"
BR2_ROOTFS_OVERLAY="../buildroot-external/rootfs-overlay"
BR2_ROOTFS_POST_BUILD_SCRIPT="../buildroot-external/board/raspberrypi3/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="../buildroot-external/board/raspberrypi3/post-image.sh"
@ -33,7 +30,6 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
BR2_PACKAGE_BUSYBOX_CONFIG="../buildroot-external/busybox.config"
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES=y
BR2_PACKAGE_ALSA_UTILS=y
BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
@ -60,6 +56,7 @@ BR2_PACKAGE_MIMIC_AUDIO_BACKEND_ALSA=y
BR2_PACKAGE_MPG123=y
BR2_PACKAGE_MPV=y
BR2_PACKAGE_PULSEAUDIO=y
BR2_PACKAGE_PULSEAUDIO_DAEMON=y
BR2_PACKAGE_VLC=y
BR2_PACKAGE_GZIP=y
BR2_PACKAGE_LZ4=y
@ -89,8 +86,9 @@ BR2_PACKAGE_RPI_WIFI_FIRMWARE=y
BR2_PACKAGE_DBUS_PYTHON=y
BR2_PACKAGE_KBD=y
BR2_PACKAGE_PARTED=y
BR2_PACKAGE_SPI_TOOLS=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON3_PY_ONLY=y
BR2_PACKAGE_PYTHON3_PY_PYC=y
BR2_PACKAGE_PYTHON3_BZIP2=y
BR2_PACKAGE_PYTHON3_CODECSCJK=y
BR2_PACKAGE_PYTHON3_CURSES=y
@ -113,7 +111,9 @@ BR2_PACKAGE_PYTHON_PSUTIL=y
BR2_PACKAGE_PYTHON_PYCLI=y
BR2_PACKAGE_PYTHON_PYCRYPTO=y
BR2_PACKAGE_PYTHON_PYTZ=y
BR2_PACKAGE_PYTHON_PYUSB=y
BR2_PACKAGE_PYTHON_SERIAL=y
BR2_PACKAGE_PYTHON_SPIDEV=y
BR2_PACKAGE_PYTHON_TEXTTABLE=y
BR2_PACKAGE_PYTHON_TORNADO=y
BR2_PACKAGE_PYTHON_WEBSOCKET_CLIENT=y
@ -139,6 +139,7 @@ BR2_PACKAGE_LIBMPEG2_BINS=y
BR2_PACKAGE_LIBTHEORA=y
BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_CURL=y
BR2_PACKAGE_LIBTIRPC=y
BR2_PACKAGE_LIBFRIBIDI=y
BR2_PACKAGE_LIBUNISTRING=y
BR2_PACKAGE_NCURSES_WCHAR=y
@ -166,11 +167,9 @@ BR2_PACKAGE_WHICH=y
BR2_PACKAGE_HTOP=y
BR2_PACKAGE_START_STOP_DAEMON=y
BR2_PACKAGE_TAR=y
BR2_PACKAGE_UTIL_LINUX_FSCK=y
BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
BR2_PACKAGE_UTIL_LINUX_KILL=y
BR2_PACKAGE_UTIL_LINUX_MORE=y
BR2_PACKAGE_UTIL_LINUX_MOUNT=y
BR2_PACKAGE_NANO=y
BR2_PACKAGE_VIM=y
# BR2_PACKAGE_VIM_RUNTIME is not set
@ -181,14 +180,20 @@ BR2_TARGET_ROOTFS_EXT2_SIZE="1024M"
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y
BR2_PACKAGE_HOST_PYTHON_CYTHON=y
BR2_PACKAGE_HOST_PYTHON_LXML=y
BR2_PACKAGE_HOST_PYTHON_SIX=y
BR2_PACKAGE_HOST_PYTHON_XLRD=y
BR2_PACKAGE_FANN=y
BR2_PACKAGE_RESPEAKER=y
BR2_PACKAGE_PYTHON_ADAPT_PARSER=y
BR2_PACKAGE_PYTHON_COLORZERO=y
BR2_PACKAGE_PYTHON_COVERALLS=y
BR2_PACKAGE_PYTHON_DEPRECATED=y
BR2_PACKAGE_PYTHON_FASTENERS=y
BR2_PACKAGE_PYTHON_FEEDPARSER=y
BR2_PACKAGE_PYTHON_GOOGLE_API_PYTHON_CLIENT=y
BR2_PACKAGE_PYTHON_GPIOZERO=y
BR2_PACKAGE_PYTHON_GTTS=y
BR2_PACKAGE_PYTHON_HUMANHASH3=y
BR2_PACKAGE_PYTHON_INFLECTION=y

View File

@ -0,0 +1,6 @@
config BR2_PACKAGE_PYTHON_COLORZERO
bool "python-colorzero"
help
Yet another Python color library.
http://colorzero.readthedocs.io/

View File

@ -0,0 +1,5 @@
# md5, sha256 from https://pypi.org/pypi/colorzero/json
md5 7581c4b7fc5f52bf41422e4bbb29731a colorzero-1.1.tar.gz
sha256 acba47119b5d8555680d3cda9afe6ccc5481385ccc3c00084dd973f7aa184599 colorzero-1.1.tar.gz
# Locally computed sha256 checksums
sha256 47778d78e05bb6c39c022814e3712a0327c6418c7251757e72167ab8ff12bb4d LICENSE.txt

View File

@ -0,0 +1,14 @@
################################################################################
#
# python-colorzero
#
################################################################################
PYTHON_COLORZERO_VERSION = 1.1
PYTHON_COLORZERO_SOURCE = colorzero-$(PYTHON_COLORZERO_VERSION).tar.gz
PYTHON_COLORZERO_SITE = https://files.pythonhosted.org/packages/08/0e/826b882db4da2970f53331969d66efc2da2071ffd9a8824601d0feff513d
PYTHON_COLORZERO_SETUP_TYPE = setuptools
PYTHON_COLORZERO_LICENSE = BSD-3-Clause
PYTHON_COLORZERO_LICENSE_FILES = LICENSE.txt
$(eval $(python-package))

View File

@ -0,0 +1,6 @@
config BR2_PACKAGE_PYTHON_GPIOZERO
bool "python-gpiozero"
help
A simple interface to GPIO devices with Raspberry Pi..
https://github.com/RPi-Distro/python-gpiozero

View File

@ -0,0 +1,3 @@
# md5, sha256 from https://pypi.org/pypi/gpiozero/json
md5 1b138b727e71e976675773e2131a8297 gpiozero-1.4.1.tar.gz
sha256 b4b074e56dea12c21b05e6feef792719a392a245f5e685bc56be3dc2546f8609 gpiozero-1.4.1.tar.gz

View File

@ -0,0 +1,12 @@
################################################################################
#
# python-gpiozero
#
################################################################################
PYTHON_GPIOZERO_VERSION = 1.4.1
PYTHON_GPIOZERO_SOURCE = gpiozero-$(PYTHON_GPIOZERO_VERSION).tar.gz
PYTHON_GPIOZERO_SITE = https://files.pythonhosted.org/packages/3b/50/377575ff8fbdb672c27869ce536813cafdd94f5e14b5bf377edabb8a8097
PYTHON_GPIOZERO_SETUP_TYPE = setuptools
$(eval $(python-package))

View File

@ -1,25 +0,0 @@
From 28a9ff65a9b71ad70b906d688b7b2f593ea108cc Mon Sep 17 00:00:00 2001
From: Peter Steenbergen <info@j1nx.nl>
Date: Fri, 5 Oct 2018 09:42:55 +0200
Subject: [PATCH 1/1] Enforce UTF8 encoding
---
mycroft/dialog/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mycroft/dialog/__init__.py b/mycroft/dialog/__init__.py
index 59b4a44a0d..59c521b929 100644
--- a/mycroft/dialog/__init__.py
+++ b/mycroft/dialog/__init__.py
@@ -45,7 +45,7 @@ class MustacheDialogRenderer(object):
template_name (str): a unique identifier for a group of templates
filename (str): a fully qualified filename of a mustache template.
"""
- with open(filename, 'r') as f:
+ with open(filename, 'r', encoding='utf-8') as f:
for line in f:
template_text = line.strip()
if template_name not in self.templates:
--
2.11.0

View File

@ -0,0 +1,26 @@
From 9fbd29b3c0442191706468fdd14270749e358211 Mon Sep 17 00:00:00 2001
From: Peter Steenbergen <info@j1nx.nl>
Date: Fri, 25 Jan 2019 13:04:53 +0100
Subject: [PATCH 1/1] Bump python-tornado requirement to 5.1.1 This because
4.5.3 does not compile on the host with Python 3.7
---
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index 94ffe987e8..5fe21dfa80 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,7 +5,7 @@ gTTS-token==1.1.3
PyAudio==0.2.11
pyee==1.0.1
SpeechRecognition==3.8.1
-tornado==4.5.3
+tornado==5.1.1
websocket-client==0.32.0
requests-futures==0.9.5
pyalsaaudio==0.8.2
--
2.11.0

View File

@ -0,0 +1,25 @@
From e5c877740c298fc07fcbadd29ca00c02cfb49ca5 Mon Sep 17 00:00:00 2001
From: Peter Steenbergen <info@j1nx.nl>
Date: Tue, 29 Jan 2019 10:25:42 +0100
Subject: [PATCH 1/1] Bump python-dateutil requirement to 2.7.5
---
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index 5fe21dfa80..7f481ccb93 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -15,7 +15,7 @@ psutil==5.2.1
pocketsphinx==0.1.0
inflection==0.3.1
pillow==4.1.1
-python-dateutil==2.6.0
+python-dateutil==2.7.5
pychromecast==0.7.7
python-vlc==1.1.2
pulsectl==17.7.4
--
2.11.0

View File

@ -5,3 +5,4 @@ sha256 42950284980d415d5cf75c91ad1e59080770cf82a12dc294f106b97fdf8c65c0 python-
sha256 35d6c2d6155ea9b1887b296164a8ee7f1abf8e58b192a4829aaa59a7592909fa python-mycroft-v18.8.5.tar.gz
sha256 14d936dea78379a58c80b2d8268be87e5e89b3147a6f48fa85c6db4c37dc8b56 python-mycroft-v18.8.10.tar.gz
sha256 f3a4dcfbf4690df6a885cab40c7069d67b61e8cd5d81f85cf892dd38b3902aff python-mycroft-v18.8.11.tar.gz
sha256 b7ddc81be63310c28bc5da1e39745429941311362364dc44b67e3bc69139bb94 python-mycroft-v18.8.12.tar.gz

View File

@ -4,7 +4,7 @@
#
################################################################################
PYTHON_MYCROFT_VERSION = v18.8.11
PYTHON_MYCROFT_VERSION = v18.8.12
PYTHON_MYCROFT_SITE = $(call github,MycroftAI,mycroft-core,release/$(PYTHON_MYCROFT_VERSION))
PYTHON_MYCROFT_SETUP_TYPE = setuptools
PYTHON_MYCROFT_LICENSE_FILES =

View File

@ -1,2 +1,3 @@
modprobe snd-bcm2835
modprobe spi-bcm2835
#modprobe snd-usb-audio

View File

@ -2,6 +2,9 @@
"play_wav_cmdline": "aplay -Dhw:0,0 %1",
"play_mp3_cmdline": "mpg123 -a hw:0,0 %1",
"ipc_path": "/ramdisk/mycroft/ipc/",
"listener": {
"mute_during_output": false
},
"ignore_logs": ["enclosure.mouth.viseme", "enclosure.mouth.display"],
"log_level": "INFO"
"log_level": "DEBUG"
}

View File

@ -0,0 +1,3 @@
[global]
only-binary=:all:
extra-index-url=https://www.piwheels.org/simple

View File

@ -0,0 +1 @@
{"window_t": 0.1, "hop_t": 0.05, "buffer_t": 1.5, "sample_rate": 16000, "sample_depth": 2, "n_mfcc": 13, "n_filt": 20, "n_fft": 512}

View File

@ -0,0 +1,79 @@
#if defined(__linux__)
# if defined(__x86_64__) && defined(__LP64__)
# include <x86_64-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__x86_64__) && defined(__ILP32__)
# include <x86_64-linux-gnux32/python3.4m/pyconfig.h>
# elif defined(__i386__)
# include <i386-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__aarch64__) && defined(__AARCH64EL__)
# include <aarch64-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__alpha__)
# include <alpha-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)
# include <arm-linux-gnueabihf/python3.4m/pyconfig.h>
# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
# include <arm-linux-gnueabi/python3.4m/pyconfig.h>
# elif defined(__hppa__)
# include <hppa-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__ia64__)
# include <ia64-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__m68k__) && !defined(__mcoldfire__)
# include <m68k-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__mips_hard_float) && defined(_MIPSEL)
# if _MIPS_SIM == _ABIO32
# include <mipsel-linux-gnu/python3.4m/pyconfig.h>
# elif _MIPS_SIM == _ABIN32
# include <mips64el-linux-gnuabin32/python3.4m/pyconfig.h>
# elif _MIPS_SIM == _ABI64
# include <mips64el-linux-gnuabi64/python3.4m/pyconfig.h>
# else
# error unknown multiarch location for pyconfig.h
# endif
# elif defined(__mips_hard_float)
# if _MIPS_SIM == _ABIO32
# include <mips-linux-gnu/python3.4m/pyconfig.h>
# elif _MIPS_SIM == _ABIN32
# include <mips64-linux-gnuabin32/python3.4m/pyconfig.h>
# elif _MIPS_SIM == _ABI64
# include <mips64-linux-gnuabi64/python3.4m/pyconfig.h>
# else
# error unknown multiarch location for pyconfig.h
# endif
# elif defined(__or1k__)
# include <or1k-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__powerpc__) && defined(__SPE__)
# include <powerpc-linux-gnuspe/python3.4m/pyconfig.h>
# elif defined(__powerpc64__)
# if defined(__LITTLE_ENDIAN__)
# include <powerpc64le-linux-gnu/python3.4m/pyconfig.h>
# else
# include <powerpc64-linux-gnu/python3.4m/pyconfig.h>
# endif
# elif defined(__powerpc__)
# include <powerpc-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__s390x__)
# include <s390x-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__s390__)
# include <s390-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
# include <sh4-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__sparc__) && defined(__arch64__)
# include <sparc64-linux-gnu/python3.4m/pyconfig.h>
# elif defined(__sparc__)
# include <sparc-linux-gnu/python3.4m/pyconfig.h>
# else
# error unknown multiarch location for pyconfig.h
# endif
#elif defined(__FreeBSD_kernel__)
# if defined(__LP64__)
# include <x86_64-kfreebsd-gnu/python3.4m/pyconfig.h>
# elif defined(__i386__)
# include <i386-kfreebsd-gnu/python3.4m/pyconfig.h>
# else
# error unknown multiarch location for pyconfig.h
# endif
#elif defined(__gnu_hurd__)
# include <i386-gnu/python3.4m/pyconfig.h>
#else
# error unknown multiarch location for pyconfig.h
#endif

View File

@ -0,0 +1,159 @@
# Grammar for 2to3. This grammar supports Python 2.x and 3.x.
# Note: Changing the grammar specified in this file will most likely
# require corresponding changes in the parser module
# (../Modules/parsermodule.c). If you can't make the changes to
# that module yourself, please co-ordinate the required changes
# with someone who can; ask around on python-dev for help. Fred
# Drake <fdrake@acm.org> will probably be listening there.
# NOTE WELL: You should also follow all the steps listed in PEP 306,
# "How to Change Python's Grammar"
# Commands for Kees Blom's railroad program
#diagram:token NAME
#diagram:token NUMBER
#diagram:token STRING
#diagram:token NEWLINE
#diagram:token ENDMARKER
#diagram:token INDENT
#diagram:output\input python.bla
#diagram:token DEDENT
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm
#diagram:rules
# Start symbols for the grammar:
# file_input is a module or sequence of commands read from an input file;
# single_input is a single interactive statement;
# eval_input is the input for the eval() and input() functions.
# NB: compound_stmt in single_input is followed by extra NEWLINE!
file_input: (NEWLINE | stmt)* ENDMARKER
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
eval_input: testlist NEWLINE* ENDMARKER
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
decorators: decorator+
decorated: decorators (classdef | funcdef)
funcdef: 'def' NAME parameters ['->' test] ':' suite
parameters: '(' [typedargslist] ')'
typedargslist: ((tfpdef ['=' test] ',')*
('*' [tname] (',' tname ['=' test])* [',' '**' tname] | '**' tname)
| tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
tname: NAME [':' test]
tfpdef: tname | '(' tfplist ')'
tfplist: tfpdef (',' tfpdef)* [',']
varargslist: ((vfpdef ['=' test] ',')*
('*' [vname] (',' vname ['=' test])* [',' '**' vname] | '**' vname)
| vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
vname: NAME
vfpdef: vname | '(' vfplist ')'
vfplist: vfpdef (',' vfpdef)* [',']
stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
import_stmt | global_stmt | exec_stmt | assert_stmt)
expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
('=' (yield_expr|testlist_star_expr))*)
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=')
# For normal assignments, additional restrictions enforced by the interpreter
print_stmt: 'print' ( [ test (',' test)* [','] ] |
'>>' test [ (',' test)+ [','] ] )
del_stmt: 'del' exprlist
pass_stmt: 'pass'
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
break_stmt: 'break'
continue_stmt: 'continue'
return_stmt: 'return' [testlist]
yield_stmt: yield_expr
raise_stmt: 'raise' [test ['from' test | ',' test [',' test]]]
import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
import_from: ('from' ('.'* dotted_name | '.'+)
'import' ('*' | '(' import_as_names ')' | import_as_names))
import_as_name: NAME ['as' NAME]
dotted_as_name: dotted_name ['as' NAME]
import_as_names: import_as_name (',' import_as_name)* [',']
dotted_as_names: dotted_as_name (',' dotted_as_name)*
dotted_name: NAME ('.' NAME)*
global_stmt: ('global' | 'nonlocal') NAME (',' NAME)*
exec_stmt: 'exec' expr ['in' test [',' test]]
assert_stmt: 'assert' test [',' test]
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
while_stmt: 'while' test ':' suite ['else' ':' suite]
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
try_stmt: ('try' ':' suite
((except_clause ':' suite)+
['else' ':' suite]
['finally' ':' suite] |
'finally' ':' suite))
with_stmt: 'with' with_item (',' with_item)* ':' suite
with_item: test ['as' expr]
with_var: 'as' expr
# NB compile.c makes sure that the default except clause is last
except_clause: 'except' [test [(',' | 'as') test]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
# Backward compatibility cruft to support:
# [ x for x in lambda: True, lambda: False if x() ]
# even while also allowing:
# lambda x: 5 if x else 2
# (But not a mix of the two)
testlist_safe: old_test [(',' old_test)+ [',']]
old_test: or_test | old_lambdef
old_lambdef: 'lambda' [varargslist] ':' old_test
test: or_test ['if' or_test 'else' test] | lambdef
or_test: and_test ('or' and_test)*
and_test: not_test ('and' not_test)*
not_test: 'not' not_test | comparison
comparison: expr (comp_op expr)*
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
star_expr: '*' expr
expr: xor_expr ('|' xor_expr)*
xor_expr: and_expr ('^' and_expr)*
and_expr: shift_expr ('&' shift_expr)*
shift_expr: arith_expr (('<<'|'>>') arith_expr)*
arith_expr: term (('+'|'-') term)*
term: factor (('*'|'@'|'/'|'%'|'//') factor)*
factor: ('+'|'-'|'~') factor | power
power: atom trailer* ['**' factor]
atom: ('(' [yield_expr|testlist_gexp] ')' |
'[' [listmaker] ']' |
'{' [dictsetmaker] '}' |
'`' testlist1 '`' |
NAME | NUMBER | STRING+ | '.' '.' '.')
listmaker: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
testlist_gexp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
lambdef: 'lambda' [varargslist] ':' test
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
subscriptlist: subscript (',' subscript)* [',']
subscript: test | [test] ':' [test] [sliceop]
sliceop: ':' [test]
exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']
testlist: test (',' test)* [',']
dictsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
(test (comp_for | (',' test)* [','])) )
classdef: 'class' NAME ['(' [arglist] ')'] ':' suite
arglist: (argument ',')* (argument [',']
|'*' test (',' argument)* [',' '**' test]
|'**' test)
argument: test [comp_for] | test '=' test # Really [keyword '='] test
comp_iter: comp_for | comp_if
comp_for: 'for' exprlist 'in' testlist_safe [comp_iter]
comp_if: 'if' old_test [comp_iter]
testlist1: test (',' test)*
# not used in grammar, but may appear in "node" passed from Parser to Compiler
encoding_decl: NAME
yield_expr: 'yield' [yield_arg]
yield_arg: 'from' test | testlist

View File

@ -0,0 +1,28 @@
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# A grammar to describe tree matching patterns.
# Not shown here:
# - 'TOKEN' stands for any token (leaf node)
# - 'any' stands for any node (leaf or interior)
# With 'any' we can still specify the sub-structure.
# The start symbol is 'Matcher'.
Matcher: Alternatives ENDMARKER
Alternatives: Alternative ('|' Alternative)*
Alternative: (Unit | NegatedUnit)+
Unit: [NAME '='] ( STRING [Repeater]
| NAME [Details] [Repeater]
| '(' Alternatives ')' [Repeater]
| '[' Alternatives ']'
)
NegatedUnit: 'not' (STRING | NAME [Details] | '(' Alternatives ')')
Repeater: '*' | '+' | '{' NUMBER [',' NUMBER] '}'
Details: '<' Alternatives '>'

Some files were not shown because too many files have changed in this diff Show More