Is there any way to have an Alex macro defined in one source file and used in other source files? In my case, I have definitions for $LowerCaseLetter and $UpperCaseLetter (these are all letters except e and O, since they have special roles in my code). How can I refer to these macros from other .x files?
Use Alex macros from another file
196 Views Asked by Paul Manta At
1
There are 1 best solutions below
Related Questions in HASKELL
- Typeclass projections as inheritance
- How to generate all possible matrices given a number n in Haskell
- Is there a way to get `cabal` to detect changes to non-Haskell source files?
- How to have fixed options using Option.Applicative in haskell?
- How can I create a thread in Haskell that will restart if it gets killed due to any reason?
- Automatic Jacobian matrix in Haskell
- Haskell writing to named pipe unexpectedly fails with `openFile: does not exist (No such device or address)`
- Why does Enum require to implement toEnum and fromEnum, if that's not enough for types larger than Int?
- Non-exhaustive patterns in function compress
- How to get terms names of GADT in Template Haskell?
- Implementing eval() function with Happy parser generator
- How to count the occurences of every element in a list in Haskell fast?
- In Haskell, what does `Con Int` mean?
- Extract a Maybe from a heterogeneous collection
- Haskell, Stack, importing module shows error "Module not found"
Related Questions in MACROS
- drop down list to decide which range my graph will plot
- Catia V5 Dynamic Hidden Line Removal With Macro Please Help Me
- Convert macro to a function but cannot concatenate inputs using std::stringstream
- Common Lisp: How to use a macro within a macro?
- How to remove the "*" in c++ macro args?
- Caused by : java. awt. HeadlessException
- When I click "enable macros" on my PowerPoint presentation, I get an error saying controls can't be activated. They're not registered on this computer
- SAS Macro Variables
- Generate unique type parameter in procedural derive macro
- unexpected interaction between macroexpand-1 and macrolet
- Can C macros be expanded in flex?
- External macro definition in header
- How to undefine and redefine a macro in C++?
- How to check if a macro argument is an integer literal in C
- How come clang and gcc don't produce a cast warning for this openssl macro, but do otherwise?
Related Questions in ALEX
- Implementing eval() function with Happy parser generator
- Parsing "case of" statement with Happy
- Haskell parser created with Alex and Happy doesn't work because of main function, someone can tell me why?
- Can LALR parser generators optionally consume unparsable input?
- GetWeeklySchedule directive not being sent by Amazon
- What may cause alex package build failure?
- Get token for any symbols in quotes in lexer
- Patter for byte when I got pattern for numbers in lexer
- Why is this lexer not parsing this input?
- How to check if a regex has an even number of one character with only 2 characters total?
- Cabal tries to build unknown package when building with alex, happy in nix-shell
- Using Alex in Haskell to make a lexer that parses Dice Rolls
- Alex requies the result token type to be some function that takes a AlexPosn
- Haskell source generated by happy has error "parse error on input 'data'"
- Alex monad wrapper difference between ; and skip
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Disproving something exists is always harder than finding something that does exist, but I think the info below does show that Alex can only get macro definitions from the .x file it is reading (other than predefinied stuff like
$white), and not via includes from other files....You can get the sourcecode for Alex by doing the following:
In src/Main.hs, predefined macros are first set in variables called
initSetEnv(charset macros$white,$printable, and "."), andinitREEnv(regexp macros, there are none). This gets passed into runP, in src/ParseMonad.hs, which is used to hold the current parsing state, including all defined macros. The initial state is set using the values passed in, but macros can be added using a function callednewSMac(ornewRMacfor regular expression macros).Since this seems to be the only way that macros can be set, it is then only a matter of some grep bookkeeping to verify the only ways that macros can be added is through an actual macro definition in the source .x file. Unsurprisingly, Alex recursively uses its own .x/.y files for .x source file parsing (src/parser.y, src/Scan.x). It is a couple of levels of indirection away, but you can verify that the only way
newSMaccan be called is through the src/Scan.x macroOther than some obvious predefined stuff, I don't believe reuse in lexers is all that typical anyway, because at the token level things are usually pretty simple (often simple tokens like
SPACE,WORD,NUMBER, and a few operators, symbols and parens are all that are needed). The complexity comes at the parsing stage, although for technical reasons, parser-includes aren't that common either (see scannerless parsing for a newer technology that does allow reuse through nesting, like javascript embedded in html.... The tools for scannerless parsing are still pretty primitive though).