Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Jupyter notebook lexicalAnalysis.ipynb

Project: test
Views: 13
Kernel: SageMath (stable)

Introduction

Line structure

Logical line

A logical line is constructed from one or more physical lines by following the explicit or implicit line joining rules.

Physical line

A physical line is a sequence of characters terminated by an end-of-line sequence ( LF , CR LF or CR ). The end of input also serves as an implicit terminator for the final physical line.When embedding Python ,source code strings should be passed to Python APIs using C conventions for newline \n (representing ASCII LF).

Comments

A comment starts with a hash character (#) that is not part of a string literal, and ends at the end of the physical line.

Encoding declarations

If a comment in the first or second line of the Python script matches the regular expression coding[=:]\s*([-\w.]+)\s*匹配多个空格,\w匹配任意字符 a-z|A-Z|0-9), this comment is processed as an encoding declaration. The recommended forms of an encoding expression are

# -*- coding: <encoding-name> -*-

which is recognized also by GNU Emacs, and

# vim:fileencoding=<encoding-name>

which is recognized by Bram Moolenaar’s VIM .If no encoding declaration is found, the default encoding is UTF-8.

x = 3 if x < 0 and "amdfdfdfdfd \ xxxxxxx"!=None and x ==0 : print("x不是正数") else : print("x是正数")
x是正数