M♪o 之學習筆記本《辰》組元︰【䷖】消息盈虛

派生碼訊

辰 龍

剝:不利有攸往。

彖曰:剝,剝也,柔變剛也。不利有攸往,小人長也。順而止之,觀象也。君子尚消息盈虛,天行也。

象曰:山附地上,剝﹔上以厚下,安宅。

初六:剝床以足,蔑貞凶。
象曰:剝床以足,以滅下也。

六二:剝床以辨,蔑貞凶。
象曰:剝床以辨,未有與也。

六三:剝之,無咎。
象曰:剝之無咎,失上下也。

六四:剝床以膚,凶。
象曰:剝床以膚,切近災也。

六五:貫魚,以宮人寵,無不利。
象曰:以宮人寵,終無尤也。

上九:碩果不食,君子得輿,小人剝廬。
象曰:君子得輿,民所載也。 小人剝廬,終不可用也。

︰ 飛飛 龍龍 祭祭。節慶。

 

派︰《 文 》文說︰

《説文解字》:米,粟實也。象禾實之形。凡米之屬皆从米。

《説文解字》:粱,米名也。从米,梁省聲。

《説文解字》:稻,稌也。从禾,舀聲。

古代所稱的 米 米,其實是 栗 栗谷, 粱 粱米等小米。今人所食的 稻 稻米,叫做大米。端午吃的 粽粽子,其由來甚古。傳說最早用於祭祀 龍 龍神,不過此時 龍 龍已離淵, 飛 飛而在天,是因為懷念大地之故鄉,所以想吃 粽粽子?還得以 箬箬葉包裹,當真叫人大惑不解!后說,荊楚之人為了紀念愛國詩人屈原,恐其投汨羅江亡命,身軀為魚蝦所毀傷,擲筒裝的 粽 粽糕以驅魚趕蝦,划 龍 龍舟以尋覓。雖說是陳聞故事嫋嫋斑斑,所幸楚辭尚存,當還能穿越千古,聽聞其人其事。

Qu_Yuan_Sang_while_Walking

陳洪綬屈子行吟圖

哀郢》屈原

皇天之不純命兮,何百姓之震愆?
民離散而相失兮,方仲春而東遷。
去故鄉而就遠兮,遵江夏以流亡。
出國門而軫懷兮,甲之朝吾以行。
發郢都而去閭兮,怊荒忽其焉極?
楫齊揚以容與兮,哀見君而不再得。
望長楸而太息兮,涕淫淫其若霰。
過夏首而西浮兮,顧龍門而不見。
心嬋媛而傷懷兮,眇不知其所跖。
順風波以從流兮,焉洋洋而為客。
凌陽侯之汜濫兮,忽翱翔之焉薄。
心絓結而不解兮,思蹇產而不釋。
將運舟而下浮兮,上洞庭而下江。
去終古之所居兮,今逍遙而來東。
羌靈魂之欲歸兮,何須臾而忘反。
背夏浦而西思兮,哀故都之日遠。
登大墳以遠望兮,聊以舒吾憂心。
哀州土之平樂兮,悲江介之遺風。
當陵陽之焉至兮,淼南渡之焉如?
曾不知夏之為丘兮,孰兩東門之可蕪?
心不怡之長久兮,憂與愁其相接。
惟郢路之遼遠兮,江與夏之不可涉。
忽若不信兮,至今九年而不復。
慘鬱郁而不通兮,蹇侘傺而含戚。
外承歡之【氵勺】約兮,諶荏弱而難持。
忠湛湛而願進兮,妒被離而鄣之。
堯舜之抗行兮,了杳杳而薄天。
眾讒人之嫉妒兮,被以不慈之偽名。
憎慍惀之修美兮,好夫人之慷慨。
眾踥蹀而日進兮,美超遠而逾邁。

亂曰:曼余目以流觀兮,冀一反之何時?

鳥飛反故鄉兮,狐死必首丘。
信非吾罪而棄逐兮,何日夜而忘之?

 

生 ︰多次閱讀 Christophe Delord 之

Toy Parser Generator
or
How to easily write parsers in Python

文件,深感欲明白這個『玩具般』的語法分析產生器之實務,除了必須精通『正規表示式』 Regular Expression ,還得了解『派生三』 Python3 的 re『萬國碼』 Unicode 之用法。因而詢之學長,告知了兩篇《 網 》網文︰

Regular Expressions

 

Text with RE

The aim of this chapter of our Python tutorial is to present a detailed led and descriptive introduction into regular expressions. This introduction will explain the theoretical aspects of regular expressions and will show you how to use them in Python scripts.

The term “regular expression”, sometimes also called regex or regexp, is originated in theoretical computer science. In theoretical computer science they are used to define a language family with certain characteristics, the so-called regular languages. A finite state machine (FSM), which accept language defined by a regular expression, exists for every regular expression. We have an implementation of (Finite State Machine in Python),

Regular Expressions are used in programming languages to filter texts or textstrings. It’s possible to check, if a text or a string matches a regular expression.

There is an aspect of regular expressions which shouldn’t go unmentioned: The syntax of regular expressions is the same for all programming and script languages, e.g. Python, Perl, Java, SED, AWK and even X#.

……

Advanced Regular Expressions

Introduction

stairway to success with Python

In our introduction to regular expressions of our tutorial we have covered the basic basic principles of regular expressions. We have shown, what the simplest regular expression looks like. We have also learnt, how to use regular expressions in Python by using the search() and the match() methods of the re module. The concept of formulating and using character classes should be well known by now, as well as the predefined character classes like \d, \D, \s, \S, and so on. You should have learnt how to match the beginning and the end of a string with a regular expression. You should know the special meaning of the question mark to make items optional. We have also introduced the quantifiers to repeat characters and groups arbitrarily or in certain ranges.

You should also be familiar with the use of grouping and the syntax and usage of back references.

Furthermore, we had explained the match objects of the re module and the information they contain and how to retrieve this information by using the methods span(), start(), end(), and group().

The introduction ended with a comprehensive example in Python.

In this chapter we will continue with our explanations of the syntax of the regular expressions. We will also explain further methods of the Python module re. E.g. how to find all the matched substrings of a regular expression. A task which needs programming in other programming languages like Perl or Java, but can be dealt with the call of one method of the re module of Python. So far, we only know how to define a choice of characters with a character class. We will demonstrate in this chapter of our tutorial, how to formulate alternations of substrings.

……

,研讀後十分珍惜。

 

碼 ︰家 習 。正好從新作家習,發現之前中文化,其實祇『貌似神離』,談不上『章』『法』。而今雖初學乍練︰

 

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import math
import operator
import string
import tpg

if tpg.__python__ == 3:
    operator.div = operator.truediv
    raw_input = input

def make_op(op):
    return {
        '加'   : operator.add,
        '減'   : operator.sub,
        '乘'   : operator.mul,
        '除'   : operator.div,
        '剩'   : operator.mod,
        '^'   : lambda x,y:x**y,
        '**'  : lambda x,y:x**y,
        '餘弦' : math.cos,
        '正弦' : math.sin,
        '切弦' : math.tan,
        'acos': math.acos,
        'asin': math.asin,
        'atan': math.atan,
        '平方' : lambda x:x*x,
        '根號': math.sqrt,
        '正值' : abs,
        'norm': lambda x,y:math.sqrt(x*x+y*y),
    }[op]

class Calc(tpg.Parser, dict):
    r"""

# 不能使用預設的 NamedGroupLexer

        set lexer = CacheLexer

        separator space '\s+' ;

        token 指數運算    '\^|\*\*'                                               make_op         token 加減運算    '[加|減]' make_op
        token 乘除運算    '[乘|除|剩]'                                                 make_op         token 函數一    '(餘弦|正弦|切弦|acos|asin|atan|平方|根號|正值)\b' make_op
        token 函數二    '(norm)\b'                                              make_op         token real      '(\d+\.\d*|\d*\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+' float
        token integer   '\d+'                                                   int         token VarId     '\w*'                                                    ;          START/e ->                 '變元' e=self.記憶()
            |   VarId/v '=' Expr/e      self[v]=e             |   Expr/e         ;          Var/self.get(v,0)-> VarId/v ;          Expr/e -> Term/e ( 加減運算/op Term/t e=op(e,t)
                         )*
        ;

        Term/t -> Fact/t ( 乘除運算/op Fact/f     t=op(t,f)                          )*         ;          Fact/f ->                 加減運算/op Fact/f f=op(0,f)
            |   Pow/f
        ;

        Pow/f -> Atom/f ( 指數運算/op Fact/e      f=op(f,e)                         )?         ;          Atom/a ->                 real/a             |   integer/a             |   Function/a             |   Var/a             |   '<img src="https://www.freesandal.org/wp-content/ql-cache/quicklatex.com-47b60ee797a9328acb352e3ae7895aa5_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="' Expr/a '" title="Rendered by QuickLaTeX.com" height="19" width="68" style="vertical-align: -5px;"/>'         ;          Function/y ->                 函數一/f '<img src="https://www.freesandal.org/wp-content/ql-cache/quicklatex.com-22e0e32183ddc257d3b853d237d23b4a_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="' Expr/x '" title="Rendered by QuickLaTeX.com" height="19" width="69" style="vertical-align: -5px;"/>' y = f(x)
            |   函數二/f '' Expr/x1 ',' Expr/x2 ''  y = f(x1,x2)         ;      """      def 記憶(self):         vars = sorted(self.items())         memory = [ "%s = %s"%(var, val) for (var, val) in vars ]         return "\n\t" + "\n\t".join(memory)  print("Calc (TPG example)") calc = Calc() while 1:     l = raw_input("\n:")     if l:         try:             print(calc(l))         except Exception:             print(tpg.exc())     else:         break # </pre>    , 已略知其『義』『理』。    <pre class="lang:sh decode:true ">pi@raspberrypi ~ python3 Calc.py 
Calc (TPG example)

:3 加 5
8

:3加5
0

:飛龍祭 = 55
55

:變元

	飛龍祭 = 55

:3 乘 (1 加 2)
9

:路人甲
0

:變元

	飛龍祭 = 55

:正弦(1)
0.8414709848078965

:

 

尚須細究『中文輸入法』,隨意進退修改輸入『字詞』,恐發生

Traceback (most recent call last):
File “Calc.py”, line 99, in <module>
l = raw_input(“\n:”)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe5 in position 9: unexpected end of data

的『錯誤』。☿☹

要是能給實習 機 機板寫一個『入出針文法』,說不定它就能變成了『自備語言』的會飛 飛之 機 機板的哩!!☿ ☺☺

 

訊 ︰航向碧海藍天,昂首高唱

競渡歌》張建封

五月五日天晴明,楊花繞江啼曉鶯。
使君未出郡齋外,江上早聞齊和聲。
使君出時皆有准,馬前已被紅旗引。
兩岸羅衣破暈香,銀釵照日如霜刃。
鼓聲三下紅旗開,兩龍躍出浮水來。
棹影斡波飛萬劍,鼓聲劈浪鳴千雷。
鼓聲漸急標將近,兩龍望標目如瞬。
坡上人呼霹靂驚,竿頭彩掛虹蜺暈。
前船搶水已得標,後船失勢空揮橈。
瘡眉血首爭不定,輸岸一朋心似燒。
隻將輸贏分罰賞,兩岸十舟五來往。
須臾戲罷各東西,競脱文身請書上。
吾今細觀競渡兒,何殊當路權相持。
不思得岸各休去,會到摧車摺楫時。