Skip to content

Commit

Permalink
[rename] Oil -> YSH in parse errors
Browse files Browse the repository at this point in the history
- In most of frontend/ and osh/
- ParseOil -> ParseYsh
  • Loading branch information
Andy C committed May 21, 2023
1 parent 0d2f731 commit 991bbce
Show file tree
Hide file tree
Showing 23 changed files with 126 additions and 128 deletions.
2 changes: 1 addition & 1 deletion frontend/builtin_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'bind',

#
# Oil
# YSH
#
'append',
'write', 'json', 'pp',
Expand Down
7 changes: 3 additions & 4 deletions frontend/flag_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
READ_SPEC.ShortFlag('-d', args.String)
READ_SPEC.ShortFlag('-p', args.String) # prompt

# Oil extensions
# YSH extensions
READ_SPEC.ShortFlag('-0') # until NUL, like -r -d ''
READ_SPEC.LongFlag('--all')
READ_SPEC.LongFlag('--line')
Expand Down Expand Up @@ -155,7 +155,6 @@


HELP_SPEC = FlagSpec('help')
# Use Oil flags? -index?
#HELP_SPEC.ShortFlag('-i') # show index
# Note: bash has help -d -m -s, which change the formatting

Expand Down Expand Up @@ -226,7 +225,7 @@ def _AddShellOptions(spec):

# Defines completion style.
OSH_SPEC.LongFlag('--completion-display', ['minimal', 'nice'], default='nice')
# TODO: Add option for Oil prompt style? RHS prompt?
# TODO: Add option for YSH prompt style? RHS prompt?

# Don't reparse a[x+1] and ``. Only valid in -n mode.
OSH_SPEC.LongFlag('--one-pass-parse')
Expand Down Expand Up @@ -354,7 +353,7 @@ def _DefineCompletionActions(spec):


#
# Pure Oil
# Pure YSH
#


Expand Down
6 changes: 3 additions & 3 deletions frontend/flag_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _FlagType(arg_type):

if arg_type is None: # implicit _FlagSpec
typ = flag_type_e.Bool
elif arg_type == args.Bool: # explicit _OilFlagSpec
elif arg_type == args.Bool:
typ = flag_type_e.Bool

elif arg_type == args.Int:
Expand Down Expand Up @@ -152,7 +152,7 @@ def _Default(arg_type, arg_default=None):

if arg_type is None:
default = value.Bool(False) # type: value_t
elif arg_type == args.Bool: # for _OilFlagSpec
elif arg_type == args.Bool:
default = value.Bool(False)

elif arg_type == args.Int:
Expand Down Expand Up @@ -182,7 +182,7 @@ def __init__(self):
self.arity1 = {} # type: Dict[str, args._Action]
self.plus_flags = [] # type: List[str]

# Oil extensions
# YSH extensions
self.actions_long = {} # type: Dict[str, args._Action]
self.defaults = {} # type: Dict[str, value_t]

Expand Down
20 changes: 10 additions & 10 deletions frontend/id_kind_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ def AddKinds(spec):
('QMark', '?'), ('Colon', ':'), # Ternary Op: a < b ? 0 : 1
('LessEqual', '<='), ('Less', '<'), ('GreatEqual', '>='), ('Great', '>'),
('DEqual', '=='), ('NEqual', '!='),
# note: these 3 are not in Oil's Expr. (Could be used in find dialect.)
# note: these 3 are not in YSH Expr. (Could be used in find dialect.)
('DAmp', '&&'), ('DPipe', '||'), ('Bang', '!'),

# Bitwise ops
('DGreat', '>>'), ('DLess', '<<'),
# Oil: ^ is exponent
# YSH: ^ is exponent
('Amp', '&'), ('Pipe', '|'), ('Caret', '^'), ('Tilde', '~'),

# 11 mutating operators: = += -= etc.
Expand Down Expand Up @@ -236,7 +236,7 @@ def AddKinds(spec):
'At', # for ${a[@]} in lex_mode_e.Arith, and detecting @[]
'ArithVarLike', # for $((var+1)). Distinct from Lit_VarLike 'var='
'BadBackslash', # for "\z", not Id.Unknown_Backslash because it's a
# syntax error in Oil, but NOT OSH
# syntax error in YSH, but NOT OSH
'CompDummy', # A fake Lit_* token to get partial words during
# completion
])
Expand Down Expand Up @@ -267,14 +267,14 @@ def AddKinds(spec):
'Great', # >
'Bang', # !

# Oil [] {}
# YSH [] {}
'LBracket',
'RBracket',
'LBrace',
'RBrace',
])

# Oil expressions use Kind.Expr and Kind.Arith (further below)
# YSH expressions use Kind.Expr and Kind.Arith (further below)
spec.AddKind('Expr', [
'Reserved', # <- means nothing but it's reserved now
'Symbol', # %foo
Expand Down Expand Up @@ -317,7 +317,7 @@ def AddKinds(spec):
# Two variants of Octal: \377, and \0377.
'Octal3', 'Octal4',
'Unicode4', 'Unicode8', # legacy
'UBraced', 'Pound', # Oil
'UBraced', 'Pound', # YSH
'Literals',
])

Expand All @@ -343,8 +343,8 @@ def AddKinds(spec):
'AndGreat', # bash &> stdout/stderr to file
'AndDGreat', # bash &>> stdout/stderr append to file

'GreatPlus', # >+ is append in Oil
'DGreatPlus', # >>+ is append to string in Oil
#'GreatPlus', # >+ is append in YSH
#'DGreatPlus', # >>+ is append to string in YSH
])

# NOTE: This is for left/right WORDS only. (( is not a word so it doesn't
Expand Down Expand Up @@ -481,7 +481,7 @@ def AddKinds(spec):
'UnaryPlus', 'UnaryMinus', # +1 and -1, to distinguish from infix.
# Actually we don't need this because we they
# will be under Expr1/Plus vs Expr2/Plus.
'NotIn', 'IsNot', # For Oil comparisons
'NotIn', 'IsNot', # For YSH comparisons
])

# NOTE: Not doing AddKindPairs() here because oil will have a different set
Expand All @@ -493,7 +493,7 @@ def AddKinds(spec):
'Esac', 'If', 'Fi', 'Then', 'Else', 'Elif', 'Function',
'Time',

# Oil keywords.
# YSH keywords.
'Const', 'Var', 'SetVar', 'SetRef', 'SetGlobal',
# later: Auto
'Proc', 'Func', 'Data', 'Enum',
Expand Down
28 changes: 14 additions & 14 deletions frontend/lexer_def.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
lexer_def.py -- A lexer for both shell and Oil.
lexer_def.py -- A lexer for both OSH and YSH.
It consists of a series of lexer modes, each with a regex -> Id mapping.
Expand Down Expand Up @@ -85,7 +85,7 @@ def R(pat, tok_type):
# https://www.gnu.org/software/bash/manual/bash.html#Double-Quotes
_DQ_BACKSLASH = [
R(r'\\[$`"\\]', Id.Lit_EscapedChar),
C('\\', Id.Lit_BadBackslash), # syntax error in Oil, but NOT in OSH
C('\\', Id.Lit_BadBackslash), # syntax error in YSH, but NOT in OSH
]

VAR_NAME_RE = r'[a-zA-Z_][a-zA-Z0-9_]*'
Expand Down Expand Up @@ -151,7 +151,7 @@ def R(pat, tok_type):
# A whitelist for efficiency. The shell language says that "anything else" is
# a literal character. In other words, a single $ \ or ! is a literal, not a
# syntax error. It's defined negatively, but let's define positive runs here.
# TODO: Add + here because it's never special? It's different for Oil though.
# TODO: Add + here because it's never special? It's different for YSH though.

# The range \x80-\xff makes sure that UTF-8 sequences are a single token.
_LITERAL_WHITELIST_REGEX = r'[\x80-\xffa-zA-Z0-9_/.\-]+'
Expand Down Expand Up @@ -186,7 +186,7 @@ def R(pat, tok_type):

# In ShCommand and DBracket states.
_EXTGLOB_BEGIN = [
C(',(', Id.ExtGlob_Comma), # Oil synonym for @(...)
C(',(', Id.ExtGlob_Comma), # YSH synonym for @(...)
C('@(', Id.ExtGlob_At),
C('*(', Id.ExtGlob_Star),
C('+(', Id.ExtGlob_Plus),
Expand Down Expand Up @@ -214,7 +214,7 @@ def R(pat, tok_type):
C('function', Id.KW_Function),
C('time', Id.KW_Time),

# Oil integration
# YSH integration
C('const', Id.KW_Const),
C('var', Id.KW_Var),
C('setvar', Id.KW_SetVar),
Expand Down Expand Up @@ -321,7 +321,7 @@ def R(pat, tok_type):
C('@', Id.Lit_At), # for detecting @[, @' etc. shopt -s parse_at_all

# @array and @func(1, c)
R('@' + VAR_NAME_RE, Id.Lit_Splice), # for Oil splicing
R('@' + VAR_NAME_RE, Id.Lit_Splice), # for YSH splicing
C('@{.', Id.Lit_AtLBraceDot), # for split builtin sub @{.myproc arg1}

R(FD_NUM + r'<', Id.Redir_Less),
Expand Down Expand Up @@ -481,13 +481,13 @@ def R(pat, tok_type):

# The main purpose for EXPR_CHARS is in regex literals, e.g. [a-z \t \n].
#
# In Oil expressions, Chars are code point integers, so \u{1234} is the same as
# In YSH expressions, Chars are code point integers, so \u{1234} is the same as
# 0x1234. And \0 is 0x0.

# In Python:
# chr(0x00012345) == u'\U00012345'
#
# In Oil:
# In YSH:
# 0x00012345 == \u{12345}
# chr(0x00012345) == chr(\u{12345}) == $'\u{012345}'

Expand Down Expand Up @@ -526,7 +526,7 @@ def R(pat, tok_type):
R(r'\\u[0-9a-fA-F]{1,4}', Id.Char_Unicode4),
R(r'\\U[0-9a-fA-F]{1,8}', Id.Char_Unicode8),

# This is an incompatible extension to make Oil strings "sane" and QSN
# This is an incompatible extension to make YSH strings "sane" and QSN
# compatible. I don't want to have yet another string syntax! A lint tool
# could get rid of the legacy stuff like \U.
_U_BRACED_CHAR,
Expand Down Expand Up @@ -774,19 +774,19 @@ def R(pat, tok_type):
]

#
# Oil lexing
# YSH lexing
#


# Valid in lex_mode_e.{Expr,DQ_Oil}
# Valid in lex_mode_e.{Expr,DQ}
# Used by oil_lang/grammar_gen.py
YSH_LEFT_SUBS = [
C('$(', Id.Left_DollarParen),
C('${', Id.Left_DollarBrace),
C('$[', Id.Left_DollarBracket), # Unused now
]

# Valid in lex_mode_e.Expr, but not valid in DQ_Oil
# Valid in lex_mode_e.Expr, but not valid in DQ
# Used by oil_lang/grammar_gen.py

YSH_LEFT_UNQUOTED = [
Expand Down Expand Up @@ -852,7 +852,7 @@ def R(pat, tok_type):

_WHITESPACE = r'[ \t\r\n]*' # not including legacy \f \v

# Used for Oil's comparison operators > >= < <=
# Used for YSH comparison operators > >= < <=
# Optional -?
LOOKS_LIKE_FLOAT = _WHITESPACE + '-?' + _SIMPLE_FLOAT_RE + _WHITESPACE

Expand Down Expand Up @@ -989,7 +989,7 @@ def R(pat, tok_type):

C('!', Id.Expr_Bang), # For eggex negation

C('//', Id.Expr_DSlash), # For Oil integer division
C('//', Id.Expr_DSlash), # For YSH integer division
C('~==', Id.Expr_TildeDEqual), # approximate equality

C('.', Id.Expr_Dot), # attribute access (static or dynamic)
Expand Down
6 changes: 3 additions & 3 deletions frontend/option_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def DoneWithImplementedOptions(self):
# Whether status 141 in pipelines is turned into 0
('sigpipe_status_ok', False),

# Can procs and shell functions be redefined? On in shell, off in Oil
# batch, on in interactive shell
# Can procs and shell functions be redefined? On in OSH, off in YSH batch,
# on in interactive shell
('redefine_proc', True),
]

Expand Down Expand Up @@ -280,7 +280,7 @@ def _Init(opt_def):
opt_def.Add(name, groups=['strict:all', 'ysh:all'])

#
# Options that enable Oil language features
# Options that enable YSH features
#

for name in _BASIC_PARSE_OPTIONS:
Expand Down
20 changes: 10 additions & 10 deletions frontend/parse_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def MakeWordParserForPlugin(self, code_str):
lx = self.MakeLexer(line_reader)
return word_parse.WordParser(self, lx, line_reader)

def _OilParser(self):
def _YshParser(self):
# type: () -> expr_parse.ExprParser
return expr_parse.ExprParser(self, self.oil_grammar, False)

Expand All @@ -325,7 +325,7 @@ def _TeaParser(self):
def ParseVarDecl(self, kw_token, lexer):
# type: (Token, Lexer) -> Tuple[command.VarDecl, Token]
""" var mylist = [1, 2, 3] """
e_parser = self._OilParser()
e_parser = self._YshParser()
with ctx_PNodeAllocator(e_parser):
pnode, last_token = e_parser.Parse(lexer, grammar_nt.oil_var_decl)

Expand All @@ -340,7 +340,7 @@ def ParseVarDecl(self, kw_token, lexer):
def ParsePlaceMutation(self, kw_token, lexer):
# type: (Token, Lexer) -> Tuple[command.PlaceMutation, Token]
""" setvar d['a'] += 1 """
e_parser = self._OilParser()
e_parser = self._YshParser()
with ctx_PNodeAllocator(e_parser):
pnode, last_token = e_parser.Parse(lexer, grammar_nt.oil_place_mutation)
if 0:
Expand All @@ -350,11 +350,11 @@ def ParsePlaceMutation(self, kw_token, lexer):

return ast_node, last_token

def ParseOilArgList(self, lx, out):
def ParseYshArgList(self, lx, out):
# type: (Lexer, ArgList) -> None
""" $f(x, y) """

e_parser = self._OilParser()
e_parser = self._YshParser()
with ctx_PNodeAllocator(e_parser):
pnode, last_token = e_parser.Parse(lx, grammar_nt.oil_arglist)

Expand All @@ -364,11 +364,11 @@ def ParseOilArgList(self, lx, out):
self.tr.ToArgList(pnode, out)
out.right = last_token

def ParseOilExpr(self, lx, start_symbol):
def ParseYshExpr(self, lx, start_symbol):
# type: (Lexer, int) -> Tuple[expr_t, Token]
""" if (x > 0) { ... }, while, etc. """

e_parser = self._OilParser()
e_parser = self._YshParser()
with ctx_PNodeAllocator(e_parser):
pnode, last_token = e_parser.Parse(lx, start_symbol)
if 0:
Expand All @@ -378,10 +378,10 @@ def ParseOilExpr(self, lx, start_symbol):

return ast_node, last_token

def ParseOilForExpr(self, lexer, start_symbol):
def ParseYshForExpr(self, lexer, start_symbol):
# type: (Lexer, int) -> Tuple[List[NameType], expr_t, Token]
""" for (x Int, y Int in foo) """
e_parser = self._OilParser()
e_parser = self._YshParser()
with ctx_PNodeAllocator(e_parser):
pnode, last_token = e_parser.Parse(lexer, start_symbol)

Expand All @@ -395,7 +395,7 @@ def ParseOilForExpr(self, lexer, start_symbol):
def ParseProc(self, lexer, out):
# type: (Lexer, command.Proc) -> Token
""" proc f(x, y, @args) { """
e_parser = self._OilParser()
e_parser = self._YshParser()
with ctx_PNodeAllocator(e_parser):
pnode, last_token = e_parser.Parse(lexer, grammar_nt.oil_proc)

Expand Down
2 changes: 1 addition & 1 deletion frontend/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def LastLineHint(self):


class DisallowedLineReader(_Reader):
"""For CommandParser in Oil expressions."""
"""For CommandParser in YSH expressions."""

def __init__(self, arena, blame_token):
# type: (Arena, Token) -> None
Expand Down
2 changes: 1 addition & 1 deletion frontend/signal_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _MakeSignalsOld():
'SIGXCPU',
'SIGXFSZ',

# Not part of POSIX, but essential for Oil to work
# Not part of POSIX, but essential for Oils to work
'SIGWINCH',
]

Expand Down

0 comments on commit 991bbce

Please sign in to comment.