Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev hoover 1 #2199

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions asdl/pybase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python2
"""pybase.py."""
"""asdl/pybase.py is a runtime library for ASDL in Python"""
from __future__ import print_function

from mycpp import mylib
Expand All @@ -10,21 +10,16 @@
from asdl.runtime import TraversalState


class Obj(object):
# NOTE: We're using CAPS for these static fields, since they are constant at
# runtime after metaprogramming.
ASDL_TYPE = None # Used for type checking


class SimpleObj(int):
"""Base type of simple sum types."""
# TODO: Get rid of this indirection? Although mycpp might use it.
"""Base type of simple sum types, which are integers."""
# TODO: Get rid of this class? mycpp uses it to tell if it should generate
# h8_id or h8_id*.
pass


class CompoundObj(Obj):
# The tag is set for variant types, which are subclasses of sum
# types. Never set for product types.
class CompoundObj(object):
# The tag is set for variant types, which are subclasses of sum types.
# It's not set for product types.
_type_tag = 0 # Starts at 1. Zero is invalid

def PrettyTree(self, do_abbrev, trav=None):
Expand All @@ -33,6 +28,8 @@ def PrettyTree(self, do_abbrev, trav=None):

def __repr__(self):
# type: () -> str
"""Print this ASDL object nicely."""

# TODO: Break this circular dependency.
from asdl import format as fmt

Expand Down
1 change: 1 addition & 0 deletions build/py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ py-codegen() {
# depends on syntax.asdl
gen-asdl-py 'core/runtime.asdl'
gen-asdl-py 'core/value.asdl'
gen-asdl-py 'data_lang/htm8.asdl'
gen-asdl-py 'data_lang/nil8.asdl'
gen-asdl-py 'display/pretty.asdl'
gen-asdl-py 'mycpp/mycpp.asdl'
Expand Down
24 changes: 24 additions & 0 deletions data_lang/htm8.asdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

module htm8
{

h8_id =
Decl

# CommentBegin, ProcessingBegin, CDataBegin are "pseudo-tokens", not visible
| Comment | CommentBegin
| Processing | ProcessingBegin
| CData | CDataBegin

| StartTag | StartEndTag | EndTag

| DecChar | HexChar | CharEntity

| RawData | HtmlCData

| BadAmpersand | BadGreaterThan | BadLessThan

| Invalid
| EndOfStream
generate [no_namespace_suffix] # cosmetic: call it h8_id, not h8_id_e
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions doctools/oils_doc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from lazylex import html
from doctools import oils_doc # module under test

with open('lazylex/testdata.html') as f:
with open('data_lang/testdata/hello.htm8') as f:
TEST_HTML = f.read()


Expand Down Expand Up @@ -58,7 +58,7 @@ def testShPrompt(self):

def testHighlightCode(self):
# type: () -> None
# lazylex/testdata.html has the language-sh-prompt
# data_lang/testdata/hello.htm8 has the language-sh-prompt

h = oils_doc.HighlightCode(TEST_HTML, None)
self.assert_('<span class="sh-prompt">' in h, h)
Expand Down
2 changes: 1 addition & 1 deletion lazylex/html_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

log = html.log

with open('lazylex/testdata.html') as f:
with open('data_lang/testdata/hello.htm8') as f:
TEST_HTML = f.read()


Expand Down
Loading