Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Apr 24, 2024
1 parent fd41dec commit e5f38a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ext/pty/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,

#if (defined(HAVE_POSIX_OPENPT) || defined(HAVE_PTSNAME)) && !defined(HAVE_PTSNAME_R)
/* glibc only, not obsolete interface on Tru64 or HP-UX */
static int
int
ptsname_r(int fd, char *buf, size_t buflen)
{
extern char *ptsname(int);
Expand Down
11 changes: 8 additions & 3 deletions ext/ripper/tools/preproc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

require 'optparse'

RIPPER_CODE_PATTERN = %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>

def main
output = nil
template = nil
Expand Down Expand Up @@ -51,13 +53,18 @@ def process(f, out, path, template)
usercode f, out, path, template
end

require_relative "dsl"

def prelude(f, out)
@exprs = {}
while line = f.gets
case line
when /\A%%/
out << "%%\n"
return
when RIPPER_CODE_PATTERN # %rule may contain /*% ripper: ... %*/ DSL
out << DSL.new($2, ($1 || "").split(",")).generate << "\n"
next
else
if (/^enum lex_state_(?:bits|e) \{/ =~ line)..(/^\}/ =~ line)
case line
Expand All @@ -74,12 +81,10 @@ def prelude(f, out)
end
end

require_relative "dsl"

def grammar(f, out)
while line = f.gets
case line
when %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
when RIPPER_CODE_PATTERN
out << DSL.new($2, ($1 || "").split(",")).generate << "\n"
when %r</\*%%%\*/>
out << "#if 0\n"
Expand Down

0 comments on commit e5f38a2

Please sign in to comment.