Permalink
Browse files

Research for a native port of OVM.

Shell functions to count lines and figure out what happens before
main().

Minor code cleanup as well.
  • Loading branch information...
Andy Chu
Andy Chu committed Jan 6, 2018
1 parent c35d3e1 commit a7179e3e1900d90ec58b18585dee7af87488a29c
Showing with 25 additions and 20 deletions.
  1. +3 −0 core/cmd_exec.py
  2. +3 −3 core/legacy.py
  3. +4 −14 core/word_eval.py
  4. +15 −3 scripts/count.sh
View
@@ -1111,6 +1111,9 @@ def RunCommandSub(self, node):
e_die('Command sub exited with status %d (%r)', status,
node.__class__.__name__)
# Runtime errors test case: # $("echo foo > $@")
# Why rstrip()?
# https://unix.stackexchange.com/questions/17747/why-does-shell-command-substitution-gobble-up-a-trailing-newline-char
return ''.join(chunks).rstrip('\n')
def RunProcessSub(self, node, op_id):
View
@@ -11,10 +11,10 @@
Other notes:
- How does this compare to awk -F?
- re.split() ? This appears not to work.
"""
import re
Idea: This is discouraged/legacy, so write it in Oil rather than C++?
Problem: Need both classes and algebraic data types.
"""
from core import runtime
from core import util
View
@@ -986,33 +986,23 @@ def __init__(self, mem, exec_opts, splitter, ex):
def _EvalCommandSub(self, node, quoted):
stdout = self.ex.RunCommandSub(node)
# Runtime errors test case: # $("echo foo > $@")
# Why rstrip()?
# https://unix.stackexchange.com/questions/17747/why-does-shell-command-substitution-gobble-up-a-trailing-newline-char
return runtime.StringPartValue(stdout, not quoted, not quoted)
return runtime.StringPartValue(stdout, not quoted)
def _EvalProcessSub(self, node, id_):
dev_path = self.ex.RunProcessSub(node, id_)
# no split or glob
return runtime.StringPartValue(dev_path, False, False)
return runtime.StringPartValue(dev_path, False) # no split or glob
class CompletionWordEvaluator(_WordEvaluator):
"""
Difference from NormalWordEvaluator: No access to executor! But they both
have a splitter.
"""
def __init__(self, mem, exec_opts, splitter):
_WordEvaluator.__init__(self, mem, exec_opts, splitter)
def _EvalCommandSub(self, node, quoted):
# Just return a dummy string?
return runtime.StringPartValue(
'__COMMAND_SUB_NOT_EXECUTED__', not quoted, not quoted)
return runtime.StringPartValue('__COMMAND_SUB_NOT_EXECUTED__', not quoted)
def _EvalProcessSub(self, node, id_):
return runtime.StringPartValue(
'__PROCESS_SUB_NOT_EXECUTED__', False, False)
return runtime.StringPartValue('__PROCESS_SUB_NOT_EXECUTED__', False)
View
@@ -110,9 +110,14 @@ parser-port() {
runtime() {
# NOTE: braces.py contains both parsing and runtime. It is a middle stage.
echo 'Core'
wc -l \
core/*_{exec,eval}.py core/{process,state}.py core/runtime.asdl | sort -n
echo 'Runtime'
wc -l core/{process,state}.py core/runtime.asdl | sort -n
echo
# NOTE: These may turn into compilers
echo 'Evaluators'
wc -l core/*_{exec,eval}.py | sort -n
echo
echo 'Builtins'
@@ -136,4 +141,11 @@ imports() {
grep --no-filename import */*.py | sort | uniq -c | sort -n
}
# For the compiler, see what's at the top level.
top-level() {
grep '^[a-zA-Z]' {core,osh}/*.py \
| grep -v '_test.py' \
| egrep -v ':import|from|class|def' # note: colon is from grep output
}
"$@"

0 comments on commit a7179e3

Please sign in to comment.