diff --git a/doc/command-vs-expression-mode.md b/doc/command-vs-expression-mode.md index 28fc1678d..73bfa4396 100644 --- a/doc/command-vs-expression-mode.md +++ b/doc/command-vs-expression-mode.md @@ -5,27 +5,76 @@ default_highlighter: oils-sh Command vs. Expression Mode =========================== -This is an essential [syntactic concept](syntactic-concepts.html) in YSH. +[YSH][] extends the shell **command** language with a Python-like +**expression** language. -YSH extends the shell **command** language with a Python-like **expression** -language. +Commands and expressions each have a **lexer mode**, which is an essential +[syntactic concept](syntactic-concepts.html) in YSH. -To implement that, the lexer enters "expression mode". +This doc lists the places where [YSH][] switches between modes. -The key difference is that when lexing commands, `unquoted` is a string, while -`$dollar` is a variable: +[YSH]: $xref - ls /bin/str $myvar - -On the other hand, when lexing expressions, `'quoted'` is a string, while -`unquoted` is a variable: +
+
+## Summary + +A main difference is whether you write strings like `unquoted` or `'quoted'`, +and whether you write variables like `$dollar` or `unquoted`: + + + + + +- thead + - Description + - Lexing Mode + - String + - Variable + - Example +- tr + - Shell-Like + - Command + - `unquoted` + - `$dollar` + - ``` + ls foo/bar $myvar + ``` +- tr + - Python-like + - Expression + - `'quoted'` + - `unquoted` + - ``` var s = myfunc('str', myvar) + ``` -This doc lists the places where we switch modes. +
+ +More examples: + + ls foo/bar # foo and bar are strings - command + var x = foo / bar # foo and bar are the names of variables - expression + +And: + + echo $filename.py # $filename is a var - command + var x = filename ++ '.py' # filename is a var - expression + + -
-
## From Command Mode to Expression Mode @@ -46,7 +95,7 @@ This includes *bare assignments* in Hay blocks: ### `=` and `call` keywords -Likewise, everything after `=` or `::` is in expression mode: +Likewise, everything after `=` or `call` is in expression mode: = 42 + f(x) @@ -102,8 +151,8 @@ Lazy arguments: Parameters aren't expressions, but they're parsed with the same lexer: - proc p(x, y) { # what's between () is in expression mode - echo "$x $y" # back to command mode + proc p (x, y) { # what's between () is in expression mode + echo "$x $y" # back to command mode } func f(x) { @@ -128,7 +177,7 @@ This is a command literal: var b = ^(echo $PWD) -## Examples +## More Examples ### How Are Glob Patterns Written in Each Mode? @@ -167,5 +216,3 @@ syntax: echo 'Python' } - -## vim: sw=2 diff --git a/doc/table-object-doc.md b/doc/table-object-doc.md index c85a94926..c4d0a9331 100644 --- a/doc/table-object-doc.md +++ b/doc/table-object-doc.md @@ -33,6 +33,12 @@ This is part of **maximal** YSH!
+## Philosophy + +- Oils is Exterior-First +- Tables, Objects, Documents - CSV, JSON, HTML + - Oils cleanup: TSV8, JSON8, HTM8 + ## Tables @@ -60,12 +66,20 @@ This is part of **maximal** YSH! - JSON Schema - tr - Document - - HTML5, XML + - HTML5 - DOM API like getElementById()
CSS selectors
- XPath? - JSX Templates - - XML Schema? + - ? +- tr + - Document + - XML + - XPath? XQuery? + - XSLT? + - three: + - DTD (document type definition, 1986) + - RelaxNG (2001) + - XML Schema aka XSD (2001) Existing @@ -125,7 +139,85 @@ This is part of **maximal** YSH! - MySQL: XML extraction functions only - sqlite: none +## Design Issues + +### Streaming + +- jq has a line-based streaming model, by taking advantage of the fact that + all JSON can be encoded without literal newlines + - HTML/XML don't have this property +- Solution: Netstring based streaming? + - can do it for both JSON8 and HTM8 ? + +### Mutual Nesting + +- JSON must be UTF-8, so JSON strings can contain JSON + - ditto for JSON8, and J8 strings +- TSV cells can't contain tabs or newlines + - so they can't contain TSV + - if you remove all the newlines, they can contain JSON +- TSV8 cells use J8 strings, so they can contain JSON, TSV +- HTM8 + - you can escape everything, so you can put another HTM8 doc inside + - and you can put JSON/JSON8 or TSV/TSV8 + - although are there whitespace rules? + - all nodes can be liek `
` nodes, preserving whitespace, until
+    - you apply another function to it
+
+### HTML5 whitespace rules
+
+- inside text context:
+  - multiple whitespace chars collapsed into a single one
+  - newlines converted to spaces
+  - leading and trailing space is preserved
+- `